When looking at the time course data, we noticed an interesting pattern: it seemed as though it would be possible to predict an individual’s group from the difference between their load effect during encoding and their load effect during delay. It seemed as though low capacity subjects had small load effects at both encoding and delay, medium capacity subjects had large load effects at both encoding and delay and high capacity subjects had large load effects at encoding but small ones at delay. As such, we wanted to create a model that used this information to predict span.
To do so, we extracted data from TR 6 for the encoding period and TR 8 for the delay period. This represented 1 TR’s worth of data in the middle of where we’d expect activity from for each period (from our model of the task convolved with a hemodynamic delay function) and where we see maximal differences between group. In addition to the raw load effects, we created two composite variables that we expected to capture the differences between groups. The first was simply the difference between load effects at encoding and delay, and the second was the sum of that difference and the load effect effect at encoding. These measures allow us to create a series of regression models to predict span, BPRS total score and accuracy at high load.
In addition to the univariate load effects, we have also seen a relationship with various measures reflecting multivariate representation across and within trial, including the probability of a MVPA classifer predicting a face at any given point in a trial and the similarity of multivariate representations across and within trials. Both of these measures were taken at each individual trial and averaged, in addition to taken from the average over many trials (which served as a template for the canonical trial type). We added these multivariate measures to see if they improved model performance when added to regression models that only contained variables based on univariate load effects.
Finally, we added in structural measures, resting state measures and EEG measures to try to explain variance at multiple different levels/modalities.
Overall, we were best able to explain variance in high load accuracy, with our best model able to explain 26% of the variance. In contrast, we were only able to explain 21% of the variance in span, and 12% of the variance in BPRS scores.
The individual components related to each of these measures will be discussed further below, but one interesting thing to note is that there is largely not much overlap. There is some overlap in the EEG measures between BPRS and span, but no overlap between span and accuracy or accuracy and BPRS. Another interesting thing to note is that when comparing PCs related to accuracy and span, those related to accuracy seem to be very much driven by the encoding and measures related to visual processing, while PCs related to span include more connectivity/multivariate measures and are also driven by delay period, or processing in DFR regions.
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.2 ✓ purrr 0.3.4
## ✓ tibble 3.0.3 ✓ dplyr 1.0.1
## ✓ tidyr 1.1.1 ✓ stringr 1.4.0
## ✓ readr 1.3.1 ✓ forcats 0.5.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(psych)
##
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
library(reshape2)
##
## Attaching package: 'reshape2'
## The following object is masked from 'package:tidyr':
##
## smiths
library(rmatio)
library(factoextra)
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
library(patchwork)
library(MASS)
##
## Attaching package: 'MASS'
## The following object is masked from 'package:patchwork':
##
## area
## The following object is masked from 'package:dplyr':
##
## select
library(caret)
## Loading required package: lattice
##
## Attaching package: 'caret'
## The following object is masked from 'package:purrr':
##
## lift
library(glmnet)
## Loading required package: Matrix
##
## Attaching package: 'Matrix'
## The following objects are masked from 'package:tidyr':
##
## expand, pack, unpack
## Loaded glmnet 4.0-2
load('data/behav.RData')
load('data/structural_measures.RData')
FA_Data <- read.csv("data/RDoC_DTI_FA_JHU_ICBM.csv")
load('data/EEG_for_PCs.RData')
load('data/connectivity_data.RData')
load('data/load_effects_DFR.RData')
load('data/split_groups_info.RData')
load('data/ITC_fusiform.RData')
similarity_fusiform <- similarity_temp
load('data/ITC_DFR_delay.RData')
similarity_DFR <- similarity_temp
load("data/MVPA_fusiform.RData")
individual_trial_probs_fusiform <- individual_trial_averages_probs
averages_from_template_fusiform <- averages_from_template
load("data/MVPA_DFR_delay_mask.RData")
individual_trial_probs_DFR <- individual_trial_averages_probs
averages_from_template_DFR <- averages_from_template
load("data/MVPA_HPC.RData")
individual_trial_probs_HPC <- individual_trial_averages_probs
averages_from_template_HPC <- averages_from_template
DFR_ROIs <- c("L aMFG","L dlPFC","L dMFG","L IPS","L preSMA","R dlPFC","R IPS","R medParietal","all delay ROIs")
source("helper_fxns/select_period_average.R")
source("helper_fxns/calc_r_squared.R")
First, we’re going to load in the time courses of the activity from the DFR regions. We’re doing this a little differently from last time, because we don’t want the interpolated data, we just want the one with 14 TRs.
We’re going to remove the subjects that aren’t included in the split group analysis, and put the data in a slightly easier to use format.
temp <- read.mat('data/RSA_DFR_trials.mat')
factors <- matrix(nrow=170)
for (idx in seq.int(1,170)){
if (constructs_fMRI$PTID[idx] %in% WM_groups[["high"]]$PTID){
factors[idx] <- "high"
}else if (constructs_fMRI$PTID[idx] %in% WM_groups[["med"]]$PTID){
factors[idx] <- "med"
}else if (constructs_fMRI$PTID[idx] %in% WM_groups[["low"]]$PTID){
factors[idx] <- "low"
}else{
factors[idx] <- "not_incl"
}
}
factors <- factor(factors, levels=c("low","med","high","not_incl"))
trial_activity_high <- temp[["trial_avg_activity_high"]]
trial_activity_low <- temp[["trial_avg_activity_low"]]
all_data <- list(subjs=constructs_fMRI$PTID,
WMC = factors,
L_aMFG = list(
high = data.frame(trial_activity_high[,,1,1]),
low = data.frame(trial_activity_low[,,1,1])
),
L_dlPFC = list(
high = data.frame(trial_activity_high[,,1,2]),
low = data.frame(trial_activity_low[,,1,2])
),
L_dMFG = list(
high = data.frame(trial_activity_high[,,1,3]),
low = data.frame(trial_activity_low[,,1,3])
),
L_IPS = list(
high = data.frame(trial_activity_high[,,1,4]),
low = data.frame(trial_activity_low[,,1,4])
),
L_preSMA = list(
high = data.frame(trial_activity_high[,,1,5]),
low = data.frame(trial_activity_low[,,1,5])
),
R_dlPFC = list(
high = data.frame(trial_activity_high[,,1,6]),
low = data.frame(trial_activity_low[,,1,6])
),
R_IPS = list(
high = data.frame(trial_activity_high[,,1,7]),
low = data.frame(trial_activity_low[,,1,7])
),
R_medParietal = list(
high = data.frame(trial_activity_high[,,1,8]),
low = data.frame(trial_activity_low[,,1,8])
),
all_delay = list(
high = data.frame(trial_activity_high[,,1,9]),
low = data.frame(trial_activity_low[,,1,9])
)
)
Now, we’re going to calculate load effects for each ROI at every time point.
for (ROI in seq.int(3,11)){
all_data[[ROI]][["load_effect"]] <- all_data[[ROI]][["high"]]-all_data[[ROI]][["low"]]
temp <- data.frame(group = all_data[["WMC"]], all_data[[ROI]][["load_effect"]])
all_data[[ROI]][["SVM"]] <- temp
}
Now, let’s pull out the encoding and delay values - we’re also going to calculate the difference between encoding and delay, and encoding + (encoding-delay), because we think that this is going to be useful. We’re going to include all these measures, plus span, in a convenient dataframe.
for (ROI in seq.int(3,11)){
temp <- data.frame(matrix(nrow=170, ncol=6))
colnames(temp) <- c("group","encoding","delay","encoding_delay","encoding_delay_comb" ,"span")
temp$group <- all_data[["WMC"]]
temp$span <- constructs_fMRI$omnibus_span_no_DFR_MRI
temp$encoding <- all_data[[ROI]][["load_effect"]][,6]
#temp$delay <- rowMeans(all_data[[ROI]][["load_effect"]][,8:9])
temp$delay <- all_data[[ROI]][["load_effect"]][,8]
temp$encoding_delay <- temp$encoding - temp$delay
temp$encoding_delay_comb <- temp$encoding + temp$encoding_delay
temp$high_acc <- p200_data$XDFR_MRI_ACC_L3[p200_data$PTID %in% constructs_fMRI$PTID]
temp$BPRS <- p200_clinical_zscores$BPRS_TOT[p200_clinical_zscores$PTID %in% constructs_fMRI$PTID]
all_data[[ROI]][["SVM_2"]] <- temp
}
All regions except for L aMFG have significant relationships
ROI_plot_list <- list()
for (ROI in seq.int(3,11)){
correlation_test <- cor.test(all_data[[ROI]][["SVM_2"]]$span,all_data[[ROI]][["SVM_2"]]$encoding_delay)
ROI_plot_list[[DFR_ROIs[ROI-2]]] <- ggplot(data=all_data[[ROI]][["SVM_2"]])+
geom_point(aes(x=span,y=encoding_delay_comb,color=group))+
stat_smooth(aes(x=span,y=encoding_delay_comb),method="lm",color="black")+
ggtitle(paste(DFR_ROIs[ROI-2], ", r = ",round(correlation_test$estimate,digits=3)))+
xlab("WM Span")+
ylab("LE Difference")+
theme_classic()
}
(ROI_plot_list[[1]] + ROI_plot_list[[2]]) /
(ROI_plot_list[[3]] + ROI_plot_list[[4]]) +
plot_annotation(title = "Correlation between (encoding LE + encoding/delay LE difference) and span ")+
plot_layout(guides="collect")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
(ROI_plot_list[[5]] + ROI_plot_list[[6]]) /
(ROI_plot_list[[7]] + ROI_plot_list[[8]]) +
plot_layout(guides="collect")
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
ROI_plot_list[[9]]
## `geom_smooth()` using formula 'y ~ x'
data_for_reg <- data.frame(span = all_data[["all_delay"]][["SVM_2"]]$span,
high_acc = all_data[["all_delay"]][["SVM_2"]]$high_acc,
BPRS = all_data[["all_delay"]][["SVM_2"]]$BPRS,
L_aMFG_enc = all_data[[3]][["SVM_2"]]$encoding,
L_aMFG_delay = all_data[[3]][["SVM_2"]]$delay,
L_dlPFC_enc = all_data[[4]][["SVM_2"]]$encoding,
L_dlPFC_delay = all_data[[4]][["SVM_2"]]$delay,
L_dMFG_enc = all_data[[5]][["SVM_2"]]$encoding,
L_dMFG_delay = all_data[[5]][["SVM_2"]]$delay,
L_IPS_enc = all_data[[6]][["SVM_2"]]$encoding,
L_IPS_delay = all_data[[6]][["SVM_2"]]$delay,
L_preSMA_enc = all_data[[7]][["SVM_2"]]$encoding,
L_preSMA_delay = all_data[[7]][["SVM_2"]]$delay,
R_dlPFC_enc = all_data[[8]][["SVM_2"]]$encoding,
R_dlPFC_delay = all_data[[8]][["SVM_2"]]$delay,
R_IPS_enc = all_data[[9]][["SVM_2"]]$encoding,
R_IPS_delay = all_data[[9]][["SVM_2"]]$delay,
R_medPar_enc = all_data[[10]][["SVM_2"]]$encoding,
R_medPar_delay = all_data[[10]][["SVM_2"]]$delay,
all_delay_enc = all_data[[11]][["SVM_2"]]$encoding,
all_delay_delay = all_data[[11]][["SVM_2"]]$delay,
L_aMFG_enc_delay = all_data[[3]][["SVM_2"]]$encoding_delay,
L_dlPFC_enc_delay = all_data[[4]][["SVM_2"]]$encoding_delay,
L_dMFG_enc_delay = all_data[[5]][["SVM_2"]]$encoding_delay,
L_IPS_enc_delay = all_data[[6]][["SVM_2"]]$encoding_delay,
L_preSMA_enc_delay = all_data[[7]][["SVM_2"]]$encoding_delay,
R_dlPFC_enc_delay = all_data[[8]][["SVM_2"]]$encoding_delay,
R_IPS_enc_delay = all_data[[9]][["SVM_2"]]$encoding_delay,
R_medPar_enc_delay = all_data[[10]][["SVM_2"]]$encoding_delay,
L_aMFG_enc_delay_comb = all_data[[3]][["SVM_2"]]$encoding_delay_comb,
L_dlPFC_enc_delay_comb = all_data[[4]][["SVM_2"]]$encoding_delay_comb,
L_dMFG_enc_delay_comb = all_data[[5]][["SVM_2"]]$encoding_delay_comb,
L_IPS_enc_delay_comb = all_data[[6]][["SVM_2"]]$encoding_delay_comb,
L_preSMA_enc_delay_comb = all_data[[7]][["SVM_2"]]$encoding_delay_comb,
R_dlPFC_enc_delay_comb = all_data[[8]][["SVM_2"]]$encoding_delay_comb,
R_IPS_enc_delay_comb = all_data[[9]][["SVM_2"]]$encoding_delay_comb,
R_medPar_enc_delay_comb = all_data[[10]][["SVM_2"]]$encoding_delay_comb,
R_all_delay_enc_delay_comb = all_data[[11]][["SVM_2"]]$encoding_delay_comb,
high_corr_fus_enc = similarity_fusiform[["high_correct_avg"]]$X6,
high_corr_fus_delay = similarity_fusiform[["high_correct_avg"]]$X8,
high_incorr_fus_enc = similarity_fusiform[["high_incorrect_avg"]]$X6,
high_incorr_fus_del = similarity_fusiform[["high_incorrect_avg"]]$X8,
low_corr_fus_enc = similarity_fusiform[["low_correct_avg"]]$X6,
low_corr_fus_del = similarity_fusiform[["low_correct_avg"]]$X8,
correct_encoding_to_correct_delay_fus = similarity_fusiform[["correct_encoding_to_correct_delay"]],
correct_enc_to_delay_fus_high_corr = similarity_fusiform[["correct_encoding_to_delay_avg"]][,4],
enc_to_correct_delay_fus_high_corr = similarity_fusiform[["encoding_to_correct_delay_avg"]][,4],
high_corr_DFR_enc = similarity_DFR[["high_correct_avg"]]$X6,
high_corr_DFR_delay = similarity_DFR[["high_correct_avg"]]$X8,
high_incorr_DFR_enc = similarity_DFR[["high_incorrect_avg"]]$X6,
high_incorr_DFR_del = similarity_DFR[["high_incorrect_avg"]]$X8,
low_corr_DFR_enc = similarity_DFR[["low_correct_avg"]]$X6,
low_corr_DFR_del = similarity_DFR[["low_correct_avg"]]$X8,
correct_encoding_to_correct_delay_DFR = similarity_DFR[["correct_encoding_to_correct_delay"]],
correct_enc_to_delay_DFR_high_corr = similarity_DFR[["correct_encoding_to_delay_avg"]][,4],
enc_to_correct_delay_DFR_high_corr = similarity_DFR[["encoding_to_correct_delay_avg"]][,4],
indiv_trial_avgs_high_correct_fusiform_enc = individual_trial_probs_fusiform[["high_correct"]]$V6,
indiv_trial_avgs_high_correct_fusiform_delay = individual_trial_probs_fusiform[["high_correct"]]$V8,
indiv_trial_avgs_high_correct_fusiform_probe = individual_trial_probs_fusiform[["high_correct"]]$V11,
indiv_trial_avgs_high_correct_DFR_enc = individual_trial_probs_DFR[["high_correct"]]$V6,
indiv_trial_avgs_high_correct_DFR_delay = individual_trial_probs_DFR[["high_correct"]]$V8,
indiv_trial_avgs_high_correct_DFR_probe = individual_trial_probs_DFR[["high_correct"]]$V11,
indiv_trial_avgs_high_incorrect_fusiform_enc = individual_trial_probs_fusiform[["high_incorrect"]]$V6,
indiv_trial_avgs_high_incorrect_fusiform_delay = individual_trial_probs_fusiform[["high_incorrect"]]$V8,
indiv_trial_avgs_high_incorrect_fusiform_probe = individual_trial_probs_fusiform[["high_incorrect"]]$V11,
indiv_trial_avgs_high_incorrect_DFR_enc = individual_trial_probs_DFR[["high_incorrect"]]$V6,
indiv_trial_avgs_high_incorrect_DFR_delay = individual_trial_probs_DFR[["high_incorrect"]]$V8,
indiv_trial_avgs_high_incorrect_DFR_probe = individual_trial_probs_DFR[["high_incorrect"]]$V11,
indiv_trial_avgs_low_correct_fusiform_enc = individual_trial_probs_fusiform[["low_correct"]]$V6,
indiv_trial_avgs_low_correct_fusiform_delay = individual_trial_probs_fusiform[["low_correct"]]$V8,
indiv_trial_avgs_low_correct_fusiform_probe = individual_trial_probs_fusiform[["low_correct"]]$V11,
indiv_trial_avgs_low_correct_DFR_enc = individual_trial_probs_DFR[["low_correct"]]$V6,
indiv_trial_avgs_low_correct_DFR_delay = individual_trial_probs_DFR[["low_correct"]]$V8,
indiv_trial_avgs_low_correct_DFR_probe = individual_trial_probs_DFR[["low_correct"]]$V11,
averages_from_template_high_correct_fusiform_enc = averages_from_template_fusiform[["high_correct"]]$V6,
averages_from_template_high_correct_fusiform_delay = averages_from_template_fusiform[["high_correct"]]$V8,
averages_from_template_high_correct_fusiform_probe = averages_from_template_fusiform[["high_correct"]]$V11,
averages_from_template_high_correct_DFR_enc = averages_from_template_DFR[["high_correct"]]$V6,
averages_from_template_high_correct_DFR_delay = averages_from_template_DFR[["high_correct"]]$V8,
averages_from_template_high_correct_DFR_probe = averages_from_template_DFR[["high_correct"]]$V11,
averages_from_template_high_incorrect_fusiform_enc = averages_from_template_fusiform[["high_incorrect"]]$V6,
averages_from_template_high_incorrect_fusiform_delay = averages_from_template_fusiform[["high_incorrect"]]$V8,
averages_from_template_high_incorrect_fusiform_probe = averages_from_template_fusiform[["high_incorrect"]]$V11,
averages_from_template_high_incorrect_DFR_enc = averages_from_template_DFR[["high_incorrect"]]$V6,
averages_from_template_high_incorrect_DFR_delay = averages_from_template_DFR[["high_incorrect"]]$V8,
averages_from_template_high_incorrect_DFR_probe = averages_from_template_DFR[["high_incorrect"]]$V11,
averages_from_template_low_correct_fusiform_enc = averages_from_template_fusiform[["low_correct"]]$V6,
averages_from_template_low_correct_fusiform_delay = averages_from_template_fusiform[["low_correct"]]$V8,
averages_from_template_low_correct_fusiform_probe = averages_from_template_fusiform[["low_correct"]]$V11,
averages_from_template_low_correct_DFR_enc = averages_from_template_DFR[["low_correct"]]$V6,
averages_from_template_low_correct_DFR_delay = averages_from_template_DFR[["low_correct"]]$V8,
averages_from_template_low_correct_DFR_probe = averages_from_template_DFR[["low_correct"]]$V11,
PTID = constructs_fMRI$PTID
)
data_for_reg <- merge(data_for_reg, p200_FFA, all = TRUE)
data_for_reg <- data_for_reg[,c(2:111,1)]
name_list <- c("alpha_cue_midOccip", "alpha_cue_Favg", "alpha_cue_Oz", "alpha_delay_midOccip", "alpha_delay_Favg", "alpha_delay_Oz", "alpha_probe_midOccip", "alpha_probe_Favg", "alpha_probe_Oz", "beta_cue_midOccip", "beta_cue_Favg", "beta_cue_Oz", "beta_delay_midOccip", "beta_delay_Favg", "beta_delay_Oz", "beta_probe_midOccip", "beta_probe_Favg", "beta_probe_Oz", "theta_cue_midOccip", "theta_cue_Favg", "theta_cue_Oz", "theta_delay_midOccip", "theta_delay_Favg", "theta_delay_Oz", "theta_probe_midOccip", "theta_probe_Favg", "theta_probe_Oz", "low_gamma_cue_midOccip", "low_gamma_cue_Favg", "low_gamma_cue_Oz", "low_gamma_delay_midOccip", "low_gamma_delay_Favg", "low_gamma_delay_Oz", "low_gamma_probe_midOccip", "low_gamma_probe_Favg", "low_gamma_probe_Oz", "cue_midOccip_n170", "probe_midOccip_n170", "cue_P3", "probe_P3")
EEG_list <- list(alpha_cue_average_midOccip, alpha_cue_average_Favg, alpha_cue_average_Oz,alpha_delay_average_midOccip, alpha_delay_average_Favg, alpha_delay_average_Oz, alpha_probe_average_midOccip, alpha_probe_average_Favg, alpha_probe_average_Oz,beta_cue_average_midOccip, beta_cue_average_Favg, beta_cue_average_Oz,beta_delay_average_midOccip, beta_delay_average_Favg, beta_delay_average_Oz, beta_probe_average_midOccip, beta_probe_average_Favg, beta_probe_average_Oz,theta_cue_average_midOccip, theta_cue_average_Favg, theta_cue_average_Oz,theta_delay_average_midOccip, theta_delay_average_Favg, theta_delay_average_Oz, theta_probe_average_midOccip, theta_probe_average_Favg, theta_probe_average_Oz,low_gamma_cue_average_midOccip, low_gamma_cue_average_Favg, low_gamma_cue_average_Oz,low_gamma_delay_average_midOccip, low_gamma_delay_average_Favg, low_gamma_delay_average_Oz, low_gamma_probe_average_midOccip, low_gamma_probe_average_Favg, low_gamma_probe_average_Oz,cue_average_midOccip_n170, probe_average_midOccip_n170, cue_average_P3, probe_average_P3 )
for (idx in seq.int(1,length(EEG_list))){
colnames(EEG_list[[idx]])[2:3] <- paste0(name_list[idx],"_",colnames(EEG_list[[idx]][2:3]),sep="")
EEG_list[[idx]] <- EEG_list[[idx]][1:3]
}
EEG_df <- Reduce(function(x,y) merge(x = x, y = y, all=TRUE), EEG_list)
EEG_df <- merge(EEG_df, CDA[,1:10], all.x=TRUE, by.x="PTID", by.y="subID")
colnames(aparc_LH_MTHICK)[2:37] <- paste0(colnames(aparc_LH_MTHICK)[2:37],"_LH", sep="")
colnames(aparc_RH_MTHICK)[2:37] <- paste0(colnames(aparc_RH_MTHICK)[2:37],"_RH", sep="")
colnames(FA_Data)[1] <- "ID"
struc_df <- Reduce(function(x,y) merge(x = x, y = y, by="ID"),
list(aparc_LH_MTHICK, aparc_RH_MTHICK,aseg, FA_Data))
# remove STD from FA
struc_df <- struc_df[,1:116]
struc_df <- data.frame(struc_df)
RS_df <- Reduce(function(x,y) merge(x=x, y=y, by = "PTID"),
list(p200_BCT_forCorr,p200_indiv_network_ParticCoeff, p200_all_RS))
RS_df <- data.frame(RS_df)
From these plots, we can see that our measures are high correlated.
pairs.panels(data_for_reg[,c(4,6,8,10,12,14,16,18)], density=TRUE)
pairs.panels(data_for_reg[,c(5,7,9,11,13,15,17,19)], density=TRUE)
pairs.panels(data_for_reg[,c(22:29)], density= TRUE)
pairs.panels(data_for_reg[,c(39:44,49:53)])
pairs.panels(data_for_reg[,c(45:47,53:56)])
pairs.panels(data_for_reg[,c(57:59,63:65,69:71)])
pairs.panels(data_for_reg[,c(60:62,66:68,72:74)])
pairs.panels(data_for_reg[,c(75:77,81:83,87:89)])
pairs.panels(data_for_reg[,c(78:80,84:86,90:92)])
We know that our variables are highly correlated, so to deal with multi-collinearity, we’re going to try to run a PCA on all the encoding load effects, delay load effects and encoding - delay. It looks like the first 3 dimensions carry most of the variance (77%), so we’re going to stick with those three.
PC1: encoding load effects and the combined encoding+encoding-delay in the PFC regions and load effect during delay PC2: delay load effect PC3: encoding - delay in parietal regions and fusiform activity during delay
res.pca <- prcomp(data_for_reg[!is.na(data_for_reg$L_CUE_LE),c(4:19, 22:37, 106:110)], scale = TRUE)
fviz_eig(res.pca)
summary(res.pca)
## Importance of components:
## PC1 PC2 PC3 PC4 PC5 PC6 PC7
## Standard deviation 3.8317 2.8690 1.7755 1.36044 1.16149 1.08876 0.99447
## Proportion of Variance 0.3968 0.2225 0.0852 0.05002 0.03646 0.03204 0.02673
## Cumulative Proportion 0.3968 0.6193 0.7045 0.75450 0.79096 0.82300 0.84973
## PC8 PC9 PC10 PC11 PC12 PC13 PC14
## Standard deviation 0.90027 0.80958 0.78333 0.76012 0.71656 0.65841 0.61265
## Proportion of Variance 0.02191 0.01771 0.01658 0.01562 0.01388 0.01172 0.01014
## Cumulative Proportion 0.87163 0.88935 0.90593 0.92155 0.93542 0.94714 0.95729
## PC15 PC16 PC17 PC18 PC19 PC20 PC21
## Standard deviation 0.54920 0.53414 0.52176 0.47660 0.45344 0.3894 0.3700
## Proportion of Variance 0.00815 0.00771 0.00736 0.00614 0.00556 0.0041 0.0037
## Cumulative Proportion 0.96544 0.97315 0.98051 0.98664 0.99220 0.9963 1.0000
## PC22 PC23 PC24 PC25 PC26
## Standard deviation 1.001e-15 3.286e-16 3.286e-16 3.286e-16 3.286e-16
## Proportion of Variance 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00
## Cumulative Proportion 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00
## PC27 PC28 PC29 PC30 PC31
## Standard deviation 3.286e-16 3.286e-16 3.286e-16 3.286e-16 3.286e-16
## Proportion of Variance 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00
## Cumulative Proportion 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00
## PC32 PC33 PC34 PC35 PC36
## Standard deviation 3.286e-16 3.286e-16 3.286e-16 3.286e-16 3.286e-16
## Proportion of Variance 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00
## Cumulative Proportion 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00
## PC37
## Standard deviation 2.265e-16
## Proportion of Variance 0.000e+00
## Cumulative Proportion 1.000e+00
res.var <- get_pca_var(res.pca)
res.var$contrib # Contributions to the PCs
## Dim.1 Dim.2 Dim.3 Dim.4
## L_aMFG_enc 5.28856171 0.37902778 6.157961e-01 0.030928862
## L_aMFG_delay 0.87514835 7.50434194 6.055440e-01 0.039678359
## L_dlPFC_enc 5.06817204 0.14920941 1.474970e+00 0.853601769
## L_dlPFC_delay 0.90616054 7.41643706 3.362529e-02 0.518352425
## L_dMFG_enc 3.85523406 0.83486192 7.684441e-01 0.104593574
## L_dMFG_delay 0.13088997 7.22260516 3.919021e-02 1.214790066
## L_IPS_enc 4.72681474 1.17282759 7.032161e-01 0.240384223
## L_IPS_delay 1.09744544 7.85264082 9.672027e-02 0.195400514
## L_preSMA_enc 5.05333421 0.26759021 1.130414e+00 1.019022415
## L_preSMA_delay 0.89809066 6.88015495 5.319551e-01 0.008823488
## R_dlPFC_enc 4.73935292 0.46232139 6.660689e-01 1.053421889
## R_dlPFC_delay 0.49515939 7.85774530 8.012236e-04 2.625527821
## R_IPS_enc 4.66486401 0.83847976 2.642182e+00 1.514621778
## R_IPS_delay 1.36497712 7.09776775 2.901157e-01 0.292800119
## R_medPar_enc 3.31551649 0.76575484 6.344154e+00 2.466090678
## R_medPar_delay 0.96321486 5.64743173 1.919158e-01 2.370647978
## L_aMFG_enc_delay 2.36929567 4.42896532 2.672597e+00 0.153234907
## L_dlPFC_enc_delay 2.59163366 4.78890802 2.369753e+00 0.118092733
## L_dMFG_enc_delay 2.48207674 3.53125606 1.158124e+00 0.675105861
## L_IPS_enc_delay 2.61058199 3.35530941 2.102327e+00 1.319237730
## L_preSMA_enc_delay 2.80635222 3.28843831 3.493193e+00 1.114055576
## R_dlPFC_enc_delay 3.06685615 3.87068237 7.844988e-01 0.183640832
## R_IPS_enc_delay 1.78102740 3.71978587 6.944083e+00 0.816801621
## R_medPar_enc_delay 1.10671832 2.64765832 1.201193e+01 0.017176427
## L_aMFG_enc_delay_comb 4.88816300 0.62517072 1.860527e+00 0.102057952
## L_dlPFC_enc_delay_comb 4.76316585 0.85743222 2.345169e+00 0.530553472
## L_dMFG_enc_delay_comb 4.28945870 0.32556806 1.307867e+00 0.086371746
## L_IPS_enc_delay_comb 4.87986967 0.04436567 1.595501e+00 0.788727952
## L_preSMA_enc_delay_comb 4.77915244 0.40562367 2.534902e+00 1.297075970
## R_dlPFC_enc_delay_comb 4.92923812 0.40923925 9.098191e-01 0.145731304
## R_IPS_enc_delay_comb 4.29112476 0.16765401 5.764064e+00 1.573412492
## R_medPar_enc_delay_comb 2.90033053 0.09957716 1.172958e+01 1.115201299
## L_DELAY_LE 0.05009231 2.05525124 8.483684e+00 0.054992419
## L_PROBE_LE 0.34549630 0.26018331 1.996965e+00 36.768046879
## R_CUE_LE 1.28086178 0.12786195 2.991150e+00 4.079700415
## R_DELAY_LE 0.01481527 2.47568695 7.542708e+00 0.200204539
## R_PROBE_LE 0.33075262 0.16618447 3.266446e+00 34.311891921
## Dim.5 Dim.6 Dim.7 Dim.8
## L_aMFG_enc 7.235748e-01 3.333941e-01 0.076352007 1.232438e-01
## L_aMFG_delay 3.509194e+00 3.505166e+00 0.191677299 8.052987e-01
## L_dlPFC_enc 2.247951e+00 1.214441e+00 0.178245671 6.168010e-01
## L_dlPFC_delay 3.096310e+00 1.564725e+00 0.041271626 3.638735e-01
## L_dMFG_enc 7.555407e-01 1.962421e+00 21.386992431 2.233940e-04
## L_dMFG_delay 5.663422e-02 7.538875e+00 0.880083005 2.609825e-01
## L_IPS_enc 2.746733e+00 2.718373e+00 0.903965109 3.606078e+00
## L_IPS_delay 1.107531e-01 8.913786e-04 1.010416142 2.087395e-02
## L_preSMA_enc 3.439487e+00 1.812855e+00 0.431125808 1.366172e+00
## L_preSMA_delay 4.472804e+00 1.024015e+00 0.030826740 1.029907e+00
## R_dlPFC_enc 1.553245e-01 4.610671e+00 6.130948222 4.560212e-02
## R_dlPFC_delay 1.955810e-01 6.977731e-01 3.109724574 2.896851e-01
## R_IPS_enc 2.813481e+00 3.283540e-02 1.481955541 6.846243e-02
## R_IPS_delay 2.573756e-02 3.684334e+00 2.006973302 1.436737e+00
## R_medPar_enc 2.645726e-02 8.054388e+00 1.432804500 4.746231e+00
## R_medPar_delay 7.548182e-01 1.466718e+01 0.452721314 2.901865e+00
## L_aMFG_enc_delay 9.503316e-01 1.610421e+00 0.549479290 1.655631e+00
## L_dlPFC_enc_delay 1.337411e-04 1.048503e-03 0.448037126 9.034739e-02
## L_dMFG_enc_delay 1.232796e+00 2.118649e+00 13.115449973 2.965985e-01
## L_IPS_enc_delay 3.133557e+00 4.745080e+00 0.005486302 6.949513e+00
## L_preSMA_enc_delay 2.663738e-02 3.565503e-01 0.815290534 1.549722e-01
## R_dlPFC_enc_delay 1.121652e-04 2.527492e+00 1.111881389 8.115718e-02
## R_IPS_enc_delay 3.592793e+00 3.932094e+00 0.014352583 1.111219e+00
## R_medPar_enc_delay 6.094053e-01 8.755190e-01 0.436380784 2.007792e+01
## L_aMFG_enc_delay_comb 9.338731e-04 1.255883e-01 0.326366141 8.378011e-01
## L_dlPFC_enc_delay_comb 7.773512e-01 4.483822e-01 0.363823456 3.889196e-01
## L_dMFG_enc_delay_comb 1.344132e+00 1.406865e-03 23.287538758 1.079815e-01
## L_IPS_enc_delay_comb 3.809198e+00 4.618671e+00 0.424499095 6.444259e+00
## L_preSMA_enc_delay_comb 1.372867e+00 1.207308e+00 0.727558988 7.906878e-01
## R_dlPFC_enc_delay_comb 5.733618e-02 4.481425e+00 4.113548089 5.927253e-04
## R_IPS_enc_delay_comb 4.211532e+00 8.238112e-01 0.514702925 1.418843e-01
## R_medPar_enc_delay_comb 9.791675e-02 1.651287e+00 1.216770171 1.406914e+01
## L_DELAY_LE 2.494714e+01 2.679230e-01 2.602743312 2.265574e+00
## L_PROBE_LE 1.866535e+00 3.968173e-01 0.547784215 1.788630e+00
## R_CUE_LE 2.880839e-01 1.493516e+01 6.995797414 1.730693e+01
## R_DELAY_LE 2.373783e+01 4.439149e-01 2.612406526 7.324654e+00
## R_PROBE_LE 2.812990e+00 1.009115e+00 0.024019640 4.335506e-01
## Dim.9 Dim.10 Dim.11 Dim.12
## L_aMFG_enc 4.7403682128 3.435853901 0.645747346 1.258687e+01
## L_aMFG_delay 0.1022843459 0.275358333 4.452872554 7.565803e-01
## L_dlPFC_enc 6.1339999504 0.001158843 4.795202808 1.266258e-01
## L_dlPFC_delay 0.4750592954 0.058596715 4.619899062 5.614144e-01
## L_dMFG_enc 0.6115759785 0.488957205 12.883977103 2.401838e-02
## L_dMFG_delay 8.2619717943 5.383452106 24.885901479 4.646307e-01
## L_IPS_enc 1.8015282819 0.122223628 1.295426406 1.163041e-02
## L_IPS_delay 0.7862711121 0.133244429 5.303409596 6.151801e-01
## L_preSMA_enc 1.4003851037 0.191712331 0.007564968 3.940104e+00
## L_preSMA_delay 0.0942600343 4.455330527 0.113601695 6.849629e+00
## R_dlPFC_enc 5.0519867188 2.015592989 2.943127200 3.239123e-02
## R_dlPFC_delay 0.2780421437 0.336534587 2.515110290 5.714481e+00
## R_IPS_enc 0.3657507564 4.427474332 0.086977127 9.519518e-01
## R_IPS_delay 1.7802120684 1.901354683 0.006643663 7.082740e-01
## R_medPar_enc 0.0073671973 2.814297534 0.079022550 1.460115e-01
## R_medPar_delay 1.5769303534 1.537065589 3.522246932 3.768368e-02
## L_aMFG_enc_delay 7.1619046996 2.168272245 1.600779663 8.728553e+00
## L_dlPFC_enc_delay 4.4762643940 0.073575206 0.150571423 1.037054e-01
## L_dMFG_enc_delay 4.8565707177 9.614501685 2.582926611 7.410024e-01
## L_IPS_enc_delay 0.5184295088 0.768447518 1.398669226 5.876767e-01
## L_preSMA_enc_delay 1.1178755869 5.880622444 0.044029170 2.150467e+01
## R_dlPFC_enc_delay 9.1711846470 1.048735441 0.141530671 4.516625e+00
## R_IPS_enc_delay 0.6156373361 1.047192532 0.211103016 5.853498e-02
## R_medPar_enc_delay 1.7021435003 0.352241279 3.130491863 5.476547e-02
## L_aMFG_enc_delay_comb 7.6332142429 3.645881995 0.047530351 1.390815e+01
## L_dlPFC_enc_delay_comb 6.6712276236 0.026661043 2.254121456 1.663086e-03
## L_dMFG_enc_delay_comb 0.7023760846 4.969722200 1.323711477 3.552705e-01
## L_IPS_enc_delay_comb 1.5025960407 0.438129185 0.021847291 9.700450e-02
## L_preSMA_enc_delay_comb 1.5419930981 2.291628063 0.003340600 1.272759e+01
## R_dlPFC_enc_delay_comb 8.6393182886 1.919118071 1.481916154 1.040484e+00
## R_IPS_enc_delay_comb 0.0003204776 3.516387721 0.181450002 5.616918e-01
## R_medPar_enc_delay_comb 0.4093412217 1.874856079 0.584018209 1.328134e-01
## L_DELAY_LE 1.5050236585 3.965963478 8.009741706 7.716488e-04
## L_PROBE_LE 0.3603784552 0.363208307 2.056479269 5.406233e-01
## R_CUE_LE 4.7721446400 15.904188758 6.070594026 3.560886e-01
## R_DELAY_LE 1.5194951649 4.712187595 0.497032249 5.162128e-04
## R_PROBE_LE 1.6545672660 7.840271421 0.051384787 4.543332e-01
## Dim.13 Dim.14 Dim.15 Dim.16
## L_aMFG_enc 0.004942722 6.111994e-01 0.291138336 2.905130844
## L_aMFG_delay 0.181753977 3.351148e-01 4.950751265 1.767548528
## L_dlPFC_enc 0.015390615 1.033148e+01 2.453533077 0.005971895
## L_dlPFC_delay 6.425510247 8.386005e-04 21.251019408 1.861595358
## L_dMFG_enc 1.524325953 1.930649e-01 0.007267323 1.358969381
## L_dMFG_delay 3.975753296 2.752255e-01 0.172521182 0.026159430
## L_IPS_enc 4.979903324 2.298592e+00 0.823857605 0.033922025
## L_IPS_delay 17.389288373 2.053338e+00 2.671671575 0.379212169
## L_preSMA_enc 3.101910349 3.816055e+00 0.052787959 12.487445744
## L_preSMA_delay 6.937524297 2.110274e+00 2.203359389 24.912742307
## R_dlPFC_enc 4.878489724 1.163335e+00 0.460779110 3.864602622
## R_dlPFC_delay 14.078496871 5.076940e+00 2.082044401 9.574100241
## R_IPS_enc 1.092678372 7.211521e-02 1.362776200 0.385554152
## R_IPS_delay 6.156503926 4.590853e-01 3.272504828 2.115890483
## R_medPar_enc 0.448502986 2.437865e+00 0.013030811 4.198369891
## R_medPar_delay 0.564597503 5.932819e+00 1.386958255 15.133143705
## L_aMFG_enc_delay 0.257080608 6.734976e-02 2.777688648 0.247644894
## L_dlPFC_enc_delay 5.295426102 1.280982e+01 7.184248530 1.960774257
## L_dMFG_enc_delay 0.707483929 1.155771e-02 0.119735913 0.980893750
## L_IPS_enc_delay 3.685161471 9.897426e-02 9.424875883 0.223249731
## L_preSMA_enc_delay 0.173809325 7.752942e-01 1.204344655 0.322789336
## R_dlPFC_enc_delay 1.393031532 1.155976e+01 0.415738729 0.658849605
## R_IPS_enc_delay 2.425905071 1.237197e+00 12.448333226 0.815456690
## R_medPar_enc_delay 0.002523359 7.794713e-01 1.401378711 3.745491697
## L_aMFG_enc_delay_comb 0.102586967 3.680977e-01 0.354366156 1.651974642
## L_dlPFC_enc_delay_comb 1.301360680 1.437740e+01 0.236988180 0.615630974
## L_dMFG_enc_delay_comb 0.051253661 3.734515e-02 0.023562446 1.592558876
## L_IPS_enc_delay_comb 0.238394024 1.291970e+00 4.466231543 0.013423942
## L_preSMA_enc_delay_comb 0.666228469 2.564860e+00 0.188574185 3.157054979
## R_dlPFC_enc_delay_comb 0.468800965 5.966504e+00 0.003706432 0.541712950
## R_IPS_enc_delay_comb 0.018194213 5.566510e-01 6.597777736 0.004716956
## R_medPar_enc_delay_comb 0.155178364 2.613717e-01 0.311079446 0.066520739
## L_DELAY_LE 0.888118260 4.903343e-01 2.050408051 1.374975915
## L_PROBE_LE 3.179673732 4.594869e+00 5.356561963 0.294915270
## R_CUE_LE 1.965964339 4.921954e+00 0.352585656 0.324648545
## R_DELAY_LE 4.677800799 6.132269e-02 0.356659522 0.386063646
## R_PROBE_LE 0.590451596 5.498393e-04 1.269153663 0.010293830
## Dim.17 Dim.18 Dim.19 Dim.20
## L_aMFG_enc 0.819956252 6.712597431 2.771298e+00 0.998570027
## L_aMFG_delay 0.273219736 29.775191172 4.065740e+00 3.853551882
## L_dlPFC_enc 1.284275486 4.502267555 2.619560e-01 0.059085349
## L_dlPFC_delay 11.099093905 7.404365417 2.038516e-01 2.884395109
## L_dMFG_enc 0.134104230 0.292675715 3.820262e-03 0.023880504
## L_dMFG_delay 1.145062169 1.353966336 1.469560e+00 0.014215902
## L_IPS_enc 1.838011228 0.506583016 2.878481e+00 5.116167037
## L_IPS_delay 0.538124090 0.374162829 4.493794e+00 11.833215959
## L_preSMA_enc 1.298700757 0.042171262 2.843870e-02 0.041547328
## L_preSMA_delay 5.621474969 0.381659055 2.472948e+00 1.641858268
## R_dlPFC_enc 0.312594419 0.505476602 3.239705e-01 2.625838621
## R_dlPFC_delay 1.456635766 0.587259284 1.875881e+00 10.988572520
## R_IPS_enc 6.148053628 0.126717662 2.725024e-01 9.149755841
## R_IPS_delay 1.052214499 6.006016181 5.780177e-01 13.016592430
## R_medPar_enc 4.608332345 0.008462164 6.838228e-01 0.100805581
## R_medPar_delay 5.430198824 1.331317870 2.198332e-01 0.393882881
## L_aMFG_enc_delay 2.271162545 7.384452807 5.749725e-02 0.818967758
## L_dlPFC_enc_delay 3.746795099 0.056930874 1.950862e-02 1.855828013
## L_dMFG_enc_delay 0.556289874 0.447806337 1.738432e+00 0.076819149
## L_IPS_enc_delay 6.816998649 2.665622283 5.997146e-02 1.073549088
## L_preSMA_enc_delay 0.773212073 0.635289193 2.652054e+00 0.885688106
## R_dlPFC_enc_delay 3.241133355 2.376054280 4.845638e-01 1.996637779
## R_IPS_enc_delay 3.590798857 5.651312117 5.157355e-02 0.158866669
## R_medPar_enc_delay 0.005381931 1.400098416 2.041656e-01 1.161573191
## L_aMFG_enc_delay_comb 1.864661210 0.002046960 7.337314e-01 0.009232233
## L_dlPFC_enc_delay_comb 0.122736111 1.278020402 1.419456e-01 0.330497238
## L_dMFG_enc_delay_comb 0.050354381 0.005986440 6.569175e-01 0.063993351
## L_IPS_enc_delay_comb 4.729655312 1.617959816 9.509130e-01 0.897181380
## L_preSMA_enc_delay_comb 0.045000619 0.284704030 8.894349e-01 0.135726040
## R_dlPFC_enc_delay_comb 1.654498756 1.535427103 9.844379e-04 0.045045203
## R_IPS_enc_delay_comb 6.581460438 0.998618246 4.705840e-02 2.994843237
## R_medPar_enc_delay_comb 1.714325433 0.326472279 5.770632e-01 0.596728250
## L_DELAY_LE 0.036919945 3.692173297 2.187440e+01 2.484354457
## L_PROBE_LE 0.978943492 0.610263014 1.534934e+01 7.624649298
## R_CUE_LE 16.104849513 1.000994101 5.369060e-02 0.113091628
## R_DELAY_LE 0.289977858 7.795232109 1.465331e+01 3.084229090
## R_PROBE_LE 1.764792245 0.323646347 1.619954e+01 10.850563603
## Dim.21 Dim.22 Dim.23 Dim.24
## L_aMFG_enc 0.144577003 2.491759e+01 0.000000e+00 0.000000e+00
## L_aMFG_delay 0.075646201 1.200522e+01 4.045232e-01 2.984372e-01
## L_dlPFC_enc 0.474113707 1.045908e+00 2.845963e+00 9.993705e+00
## L_dlPFC_delay 0.017973076 7.575030e-01 9.521463e-01 7.563448e+00
## L_dMFG_enc 0.181426138 5.075256e-01 4.313550e+00 1.761025e+00
## L_dMFG_delay 0.111615408 6.516712e-01 3.863739e+00 7.559816e-02
## L_IPS_enc 1.957235908 7.519844e+00 1.289790e+00 7.704619e-01
## L_IPS_delay 9.258832739 1.141002e+00 7.800398e-01 6.043188e+00
## L_preSMA_enc 0.279280837 3.954356e+00 1.759697e+00 1.062290e+01
## L_preSMA_delay 0.374055540 8.970408e-01 2.374211e-01 5.470634e+00
## R_dlPFC_enc 0.466731299 1.190213e+00 1.331297e+01 1.821224e+00
## R_dlPFC_delay 0.455025389 7.506348e-01 3.762975e+00 1.847291e-01
## R_IPS_enc 3.340854305 1.778964e-01 9.778525e-01 2.886026e+00
## R_IPS_delay 12.069030627 3.032558e-02 8.015839e+00 9.008005e-01
## R_medPar_enc 0.227226864 3.801884e-01 2.552165e-01 5.437817e-02
## R_medPar_delay 0.377130643 2.707326e-01 5.745155e-02 1.449692e-02
## L_aMFG_enc_delay 0.474699835 4.992457e+00 1.582767e+00 1.167687e+00
## L_dlPFC_enc_delay 0.414240844 7.395274e+00 2.743363e-01 8.387683e+00
## L_dMFG_enc_delay 0.005884252 7.053250e-01 2.891606e+00 3.482193e+00
## L_IPS_enc_delay 2.886477128 6.823045e-02 4.281912e-01 1.279774e+01
## L_preSMA_enc_delay 0.001468519 9.796320e-02 5.013371e+00 4.988863e+00
## R_dlPFC_enc_delay 0.011654823 6.486993e-01 5.264503e-01 1.041924e-01
## R_IPS_enc_delay 2.989771940 1.392165e-03 1.702240e+01 7.864644e-02
## R_medPar_enc_delay 0.015505696 2.106519e+00 2.204927e-07 3.117851e-04
## L_aMFG_enc_delay_comb 0.365121335 4.711160e+00 1.311019e+00 9.672050e-01
## L_dlPFC_enc_delay_comb 0.558483778 1.183691e+01 8.615898e-01 5.610230e-03
## L_dMFG_enc_delay_comb 0.086202313 1.091623e-02 1.102825e-01 7.428880e+00
## L_IPS_enc_delay_comb 0.003567181 5.680499e+00 4.852669e-02 8.517459e+00
## L_preSMA_enc_delay_comb 0.108658881 1.944313e+00 1.083106e+01 3.918407e-01
## R_dlPFC_enc_delay_comb 0.213982551 2.555272e-02 5.714920e+00 2.078399e+00
## R_IPS_enc_delay_comb 0.076977051 1.336515e-01 1.039293e+01 1.113664e+00
## R_medPar_enc_delay_comb 0.054378258 3.443476e+00 1.613786e-01 2.857113e-02
## L_DELAY_LE 12.899412631 2.530792e-31 4.814825e-31 7.225247e-31
## L_PROBE_LE 14.719639212 1.203706e-31 4.627047e-30 2.023430e-30
## R_CUE_LE 0.053659280 4.814825e-33 1.012317e-30 1.560003e-30
## R_DELAY_LE 17.613953448 1.083336e-30 2.708339e-31 2.330375e-30
## R_PROBE_LE 16.635505357 1.925930e-32 8.137054e-31 4.814825e-33
## Dim.25 Dim.26 Dim.27 Dim.28
## L_aMFG_enc 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
## L_aMFG_delay 7.166360e-01 8.910139e-01 6.073838e-02 3.034881e-01
## L_dlPFC_enc 3.806208e+00 1.273468e+00 1.500117e+00 7.174468e+00
## L_dlPFC_delay 8.066024e-05 6.077014e-02 1.621906e-01 3.335568e+00
## L_dMFG_enc 2.305233e-01 6.726809e-02 3.681434e-02 3.008419e-03
## L_dMFG_delay 4.941686e+00 4.579809e-01 3.928729e-01 3.889499e-01
## L_IPS_enc 5.379813e+00 7.804933e-03 1.745099e-01 2.079653e+00
## L_IPS_delay 9.413069e-01 5.468281e-02 7.543571e-01 2.469022e+00
## L_preSMA_enc 7.697369e+00 3.927005e+00 1.461034e+00 7.817103e-01
## L_preSMA_delay 1.873093e+00 1.425819e+00 3.080841e-01 1.035822e+00
## R_dlPFC_enc 1.052322e-03 3.407421e-04 8.334136e+00 8.670113e-02
## R_dlPFC_delay 3.683579e-02 9.533498e-05 5.393603e+00 1.852654e+00
## R_IPS_enc 4.051594e+00 6.056658e-01 1.116070e+01 7.408948e+00
## R_IPS_delay 4.991417e+00 4.595268e+00 4.988216e+00 1.856445e+00
## R_medPar_enc 3.093183e+00 4.858458e-01 2.387531e+01 6.775718e+00
## R_medPar_delay 3.531411e-02 4.515128e-01 1.480371e+01 1.360775e+01
## L_aMFG_enc_delay 2.803962e+00 3.486245e+00 2.376494e-01 1.187449e+00
## L_dlPFC_enc_delay 3.087763e+00 2.303524e+00 6.492829e-02 1.980200e+00
## L_dMFG_enc_delay 1.447126e+01 1.090229e+00 1.965639e+00 1.317025e+00
## L_IPS_enc_delay 1.113415e-02 1.132783e-01 1.395132e+00 2.589006e+00
## L_preSMA_enc_delay 2.915070e-01 1.904942e+01 2.104839e-02 2.085902e+00
## R_dlPFC_enc_delay 1.335176e-01 1.336617e-03 4.807039e+00 6.420336e+00
## R_IPS_enc_delay 5.115662e+00 9.610283e+00 1.415350e+00 3.036904e-02
## R_medPar_enc_delay 1.329882e+00 3.723123e-01 7.486350e+00 1.923286e+01
## L_aMFG_enc_delay_comb 2.322545e+00 2.887687e+00 1.968470e-01 9.835743e-01
## L_dlPFC_enc_delay_comb 1.097285e+01 5.717370e+00 1.627402e+00 8.618490e-01
## L_dMFG_enc_delay_comb 7.991258e+00 4.443522e-01 1.843850e+00 8.647555e-01
## L_IPS_enc_delay_comb 3.609451e+00 7.296358e-02 7.476399e-01 2.527401e-01
## L_preSMA_enc_delay_comb 3.407232e+00 3.480867e+01 7.941199e-01 4.080296e-01
## R_dlPFC_enc_delay_comb 1.006430e-01 2.503249e-03 1.334176e-01 4.585257e+00
## R_IPS_enc_delay_comb 3.825526e-01 5.734929e+00 2.123182e+00 3.830921e+00
## R_medPar_enc_delay_comb 6.172671e+00 3.573775e-04 1.734010e+00 4.209825e+00
## L_DELAY_LE 3.277090e-31 5.484386e-32 4.701977e-32 3.130840e-30
## L_PROBE_LE 3.900008e-31 2.891904e-31 1.647874e-30 1.738152e-30
## R_CUE_LE 1.203706e-31 1.203706e-31 4.478991e-30 2.547042e-30
## R_DELAY_LE 3.009266e-32 3.478711e-31 6.093763e-31 8.902611e-30
## R_PROBE_LE 1.733337e-31 5.825938e-31 3.009266e-32 7.703720e-32
## Dim.29 Dim.30 Dim.31 Dim.32
## L_aMFG_enc 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
## L_aMFG_delay 4.435744e-01 7.858842e-01 8.959597e-01 1.859400e-01
## L_dlPFC_enc 1.954221e+01 2.636715e+00 9.655867e-02 1.607464e+00
## L_dlPFC_delay 9.761216e+00 1.256853e-02 1.537981e+00 7.817782e-01
## L_dMFG_enc 9.025525e+00 1.944740e+01 1.285796e+00 1.015507e+00
## L_dMFG_delay 5.154529e+00 2.244502e+00 3.580931e+00 1.091253e+00
## L_IPS_enc 1.384053e+00 9.170298e+00 1.191494e-02 1.542111e+01
## L_IPS_delay 1.520974e+00 5.490685e+00 2.037201e+00 1.474735e+00
## L_preSMA_enc 3.416075e-01 2.439720e+00 6.973070e+00 5.011995e+00
## L_preSMA_delay 6.394295e-01 4.395822e-01 6.338308e+00 1.961774e+00
## R_dlPFC_enc 4.604881e-01 1.369244e+00 1.253289e+00 6.890838e+00
## R_dlPFC_delay 8.835225e-01 7.023752e-01 4.176843e+00 7.928372e-01
## R_IPS_enc 4.008396e+00 7.789292e-01 7.080140e-02 2.689563e+00
## R_IPS_delay 8.412724e-02 1.336861e+00 6.919868e-02 2.130348e-03
## R_medPar_enc 6.446743e-02 1.876001e+00 1.620577e-02 1.461672e+00
## R_medPar_delay 8.375948e-01 1.162606e+00 5.432419e-02 1.084159e+00
## L_aMFG_enc_delay 1.735561e+00 3.074907e+00 3.505596e+00 7.275223e-01
## L_dlPFC_enc_delay 6.508079e+00 1.474067e+00 8.140890e+00 4.998376e-01
## L_dMFG_enc_delay 1.835276e+00 2.400959e+00 6.291471e+00 1.000762e+00
## L_IPS_enc_delay 1.509437e+00 2.973725e+00 6.517631e+00 8.453791e-01
## L_preSMA_enc_delay 1.518343e+00 4.736037e-03 1.005845e+01 1.174450e+00
## R_dlPFC_enc_delay 1.755906e+00 4.576263e-01 1.023511e+01 2.663799e-01
## R_IPS_enc_delay 4.489747e+00 1.687031e+00 4.515973e-01 1.543214e+00
## R_medPar_enc_delay 3.421372e+00 5.874843e-01 2.746722e-01 8.313675e+00
## L_aMFG_enc_delay_comb 1.437580e+00 2.546972e+00 2.903715e+00 6.026129e-01
## L_dlPFC_enc_delay_comb 1.730574e+00 6.358702e+00 8.797607e+00 1.605363e-01
## L_dMFG_enc_delay_comb 2.019292e+00 2.598695e+01 1.353903e+00 1.416074e-04
## L_IPS_enc_delay_comb 1.060189e-01 3.695065e-01 7.030869e+00 1.569347e+01
## L_preSMA_enc_delay_comb 4.759262e-01 1.602739e+00 6.501637e-01 7.472820e-01
## R_dlPFC_enc_delay_comb 4.593310e-01 1.212209e-01 4.299479e+00 7.283939e+00
## R_IPS_enc_delay_comb 1.307646e+01 3.234054e-01 7.374202e-01 6.171262e+00
## R_medPar_enc_delay_comb 3.769383e+00 1.365917e-01 3.530396e-01 1.349677e+01
## L_DELAY_LE 2.437505e-30 3.081488e-31 1.807440e-32 3.510007e-30
## L_PROBE_LE 3.900008e-31 4.814825e-33 4.814825e-33 3.900008e-31
## R_CUE_LE 1.560003e-30 3.254822e-30 5.085659e-30 7.136774e-30
## R_DELAY_LE 3.900008e-31 6.933348e-31 4.701977e-32 1.203706e-33
## R_PROBE_LE 3.510007e-30 3.478711e-31 1.806312e-31 5.403437e-30
## Dim.33 Dim.34 Dim.35 Dim.36
## L_aMFG_enc 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
## L_aMFG_delay 4.427554e+00 1.880998e+00 2.321548e-01 3.075290e-01
## L_dlPFC_enc 2.708211e+00 1.036987e-01 2.199278e+00 3.726118e-01
## L_dlPFC_delay 2.026855e+00 1.569075e-01 3.277099e-01 1.146939e+00
## L_dMFG_enc 2.168059e-01 3.554496e+00 5.310239e+00 5.418119e+00
## L_dMFG_delay 3.826961e-03 8.931840e-04 6.130452e+00 5.610559e+00
## L_IPS_enc 3.211794e-03 6.839875e-01 3.365702e+00 6.180774e+00
## L_IPS_delay 2.123239e-01 1.366030e+00 5.902072e+00 2.675705e+00
## L_preSMA_enc 3.036762e+00 3.899460e+00 3.556822e+00 1.337515e-01
## L_preSMA_delay 1.776582e+00 4.242897e-01 3.394650e+00 7.477198e-03
## R_dlPFC_enc 9.302562e-01 1.470640e+01 4.657563e+00 1.515112e+00
## R_dlPFC_delay 1.737174e+00 3.682869e+00 3.972594e-01 4.748050e+00
## R_IPS_enc 1.458469e+00 1.535464e-01 1.596501e+00 1.999135e+01
## R_IPS_delay 2.548810e+00 1.204240e-01 1.457366e+00 3.656490e+00
## R_medPar_enc 1.141213e+01 4.794173e+00 4.660134e-01 1.757839e+00
## R_medPar_delay 4.119013e-01 1.217734e+00 2.874940e-01 9.089988e-02
## L_aMFG_enc_delay 1.732357e+01 7.359727e+00 9.083457e-01 1.203260e+00
## L_dlPFC_enc_delay 2.223300e+00 2.872251e-01 1.750374e-02 2.825268e+00
## L_dMFG_enc_delay 1.220655e-01 3.823562e+00 6.030721e+00 4.952132e+00
## L_IPS_enc_delay 5.677660e-01 7.064158e+00 7.792901e+00 8.419738e-01
## L_preSMA_enc_delay 1.888727e+00 1.034746e-01 5.579926e+00 1.803881e-02
## R_dlPFC_enc_delay 3.409512e+00 2.667911e-01 1.039266e+01 1.140855e+01
## R_IPS_enc_delay 3.248232e+00 8.453655e-01 1.167065e+00 7.868104e-02
## R_medPar_enc_delay 2.935836e+00 1.381320e-02 1.442797e-01 3.408844e-01
## L_aMFG_enc_delay_comb 1.434926e+01 6.096125e+00 7.523904e-01 9.966706e-01
## L_dlPFC_enc_delay_comb 5.423634e-04 5.565893e-02 1.897897e+00 1.160586e+00
## L_dMFG_enc_delay_comb 4.849584e-01 1.075859e+01 1.343891e-02 1.003448e-02
## L_IPS_enc_delay_comb 5.096030e-01 1.097080e+01 1.927426e+00 9.999080e-01
## L_preSMA_enc_delay_comb 2.591972e-02 3.978785e+00 4.482694e-01 1.949225e-01
## R_dlPFC_enc_delay_comb 8.620655e-01 7.533058e+00 2.360768e+01 4.613459e+00
## R_IPS_enc_delay_comb 6.437915e-01 1.431896e+00 3.533604e-03 1.416809e+01
## R_medPar_enc_delay_comb 1.849399e+01 2.665061e+00 3.468765e-02 2.574331e+00
## L_DELAY_LE 1.880791e-33 1.391484e-30 9.103028e-31 7.042105e-31
## L_PROBE_LE 8.137054e-31 1.264644e-31 2.034264e-31 1.880791e-33
## R_CUE_LE 3.081488e-31 3.900008e-31 3.478711e-31 4.190101e-30
## R_DELAY_LE 1.083336e-32 2.437505e-30 2.708339e-31 7.373453e-31
## R_PROBE_LE 2.225653e-30 1.692712e-32 1.194377e-30 7.981325e-31
## Dim.37
## L_aMFG_enc 3.084328e+01
## L_aMFG_delay 8.258684e+00
## L_dlPFC_enc 8.449653e-01
## L_dlPFC_delay 6.119697e-01
## L_dMFG_enc 4.100186e-01
## L_dMFG_delay 5.264705e-01
## L_IPS_enc 6.075113e+00
## L_IPS_delay 9.217897e-01
## L_preSMA_enc 3.194635e+00
## L_preSMA_delay 7.246992e-01
## R_dlPFC_enc 9.615468e-01
## R_dlPFC_delay 6.064210e-01
## R_IPS_enc 1.437185e-01
## R_IPS_delay 2.449935e-02
## R_medPar_enc 3.071457e-01
## R_medPar_delay 2.187188e-01
## L_aMFG_enc_delay 2.972876e-01
## L_dlPFC_enc_delay 5.974476e+00
## L_dMFG_enc_delay 5.698163e-01
## L_IPS_enc_delay 5.512185e-02
## L_preSMA_enc_delay 7.914228e-02
## R_dlPFC_enc_delay 5.240696e-01
## R_IPS_enc_delay 1.124699e-03
## R_medPar_enc_delay 1.701809e+00
## L_aMFG_enc_delay_comb 1.748144e+01
## L_dlPFC_enc_delay_comb 9.562777e+00
## L_dMFG_enc_delay_comb 8.818974e-03
## L_IPS_enc_delay_comb 4.589148e+00
## L_preSMA_enc_delay_comb 1.570767e+00
## R_dlPFC_enc_delay_comb 2.064347e-02
## R_IPS_enc_delay_comb 1.079740e-01
## R_medPar_enc_delay_comb 2.781908e+00
## L_DELAY_LE 1.156762e-30
## L_PROBE_LE 4.814825e-33
## R_CUE_LE 1.925930e-32
## R_DELAY_LE 3.081488e-31
## R_PROBE_LE 0.000000e+00
for (axis in seq.int(1,3)){
print(fviz_contrib(res.pca, choice = "var", axes = axis, top = 10))
}
fviz_pca_var(res.pca,
col.var = "contrib", # Color by contributions to the PC
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE # Avoid text overlapping
)
We’re going to the same thing for the similarity measures, since we have the same issue (though not quite as badly).
We cover 78% of the variance by PC5, so we’ll focus on those.
PC1: Similarity within trial PC2: Individual to template DFR trials - particularly correct trials PC3: High load correct trials in DFR, encoding to correct delay trials in high load correct trials in fusiform PC4: Similarity within high load incorrect trials during delay and encoding PC5: Correlation within low correct and high incorrect trials in DFR mask
res_sim.pca <- prcomp(data_for_reg[,c(39:56)], scale = TRUE)
fviz_eig(res_sim.pca)
summary(res_sim.pca)
## Importance of components:
## PC1 PC2 PC3 PC4 PC5 PC6 PC7
## Standard deviation 2.6812 1.5703 1.25092 1.07857 0.99578 0.92715 0.83264
## Proportion of Variance 0.3994 0.1370 0.08693 0.06463 0.05509 0.04776 0.03852
## Cumulative Proportion 0.3994 0.5364 0.62330 0.68793 0.74302 0.79078 0.82929
## PC8 PC9 PC10 PC11 PC12 PC13 PC14
## Standard deviation 0.74977 0.70015 0.67719 0.58768 0.57033 0.50182 0.47232
## Proportion of Variance 0.03123 0.02723 0.02548 0.01919 0.01807 0.01399 0.01239
## Cumulative Proportion 0.86052 0.88776 0.91323 0.93242 0.95049 0.96448 0.97688
## PC15 PC16 PC17 PC18
## Standard deviation 0.37334 0.33247 0.30531 0.27034
## Proportion of Variance 0.00774 0.00614 0.00518 0.00406
## Cumulative Proportion 0.98462 0.99076 0.99594 1.00000
res_sim.var <- get_pca_var(res_sim.pca)
res_sim.var$contrib # Contributions to the PCs
## Dim.1 Dim.2 Dim.3
## high_corr_fus_enc 7.196219174 5.826513e+00 0.1539015
## high_corr_fus_delay 8.117994270 5.555599e-01 0.1640140
## high_incorr_fus_enc 5.366195312 4.338158e+00 0.2148803
## high_incorr_fus_del 4.380847724 4.351503e-03 0.1662252
## low_corr_fus_enc 5.496251617 2.628659e+00 0.8852650
## low_corr_fus_del 8.366678725 4.898077e-01 1.4524503
## correct_encoding_to_correct_delay_fus 6.718508924 2.758920e-01 15.1079666
## correct_enc_to_delay_fus_high_corr 7.724624982 1.413991e+00 11.7045798
## enc_to_correct_delay_fus_high_corr 7.989661190 1.251987e-02 17.7113612
## high_corr_DFR_enc 8.898199520 6.360282e-01 2.6109736
## high_corr_DFR_delay 5.069267280 9.803937e-03 19.2544324
## high_incorr_DFR_enc 7.920286544 5.527401e-04 3.9324003
## high_incorr_DFR_del 3.616816785 3.356475e-01 11.1316498
## low_corr_DFR_enc 5.285301964 4.026903e-02 9.3442007
## low_corr_DFR_del 4.903066434 3.710666e+00 3.8446318
## correct_encoding_to_correct_delay_DFR 1.301530019 2.873840e+01 0.1149852
## correct_enc_to_delay_DFR_high_corr 0.005598827 2.781642e+01 0.9880859
## enc_to_correct_delay_DFR_high_corr 1.642950711 2.316677e+01 1.2179964
## Dim.4 Dim.5 Dim.6
## high_corr_fus_enc 12.087537058 2.5547690 0.005303017
## high_corr_fus_delay 4.651788771 6.1547313 5.564258485
## high_incorr_fus_enc 14.022096459 6.0689676 0.959986711
## high_incorr_fus_del 12.331486821 4.8641789 32.908407963
## low_corr_fus_enc 14.348771719 0.4263629 12.785687506
## low_corr_fus_del 2.862868792 6.3003579 7.397779547
## correct_encoding_to_correct_delay_fus 0.820884630 0.8646107 10.389806293
## correct_enc_to_delay_fus_high_corr 5.844233217 0.9252021 2.587642296
## enc_to_correct_delay_fus_high_corr 0.059949664 0.3866793 5.326825824
## high_corr_DFR_enc 1.926424993 0.4210504 6.117879793
## high_corr_DFR_delay 2.322951419 0.4173496 10.901283497
## high_incorr_DFR_enc 0.013247974 10.7369177 0.678332171
## high_incorr_DFR_del 14.862001136 13.2686003 0.112392458
## low_corr_DFR_enc 0.474470017 20.1872052 0.917016965
## low_corr_DFR_del 0.003411146 21.7314260 0.486530295
## correct_encoding_to_correct_delay_DFR 3.417712154 2.8269117 0.385068237
## correct_enc_to_delay_DFR_high_corr 0.088401984 1.2966512 0.344207667
## enc_to_correct_delay_DFR_high_corr 9.861762045 0.5680282 2.131591273
## Dim.7 Dim.8 Dim.9
## high_corr_fus_enc 1.34070989 3.763024e-01 0.09440811
## high_corr_fus_delay 8.58783204 1.241478e+01 0.04726598
## high_incorr_fus_enc 0.33877235 3.448456e-01 19.64617457
## high_incorr_fus_del 10.87363469 9.094990e-01 0.58645511
## low_corr_fus_enc 10.21348499 8.317675e+00 4.95064251
## low_corr_fus_del 0.31921280 1.243374e+00 10.35445038
## correct_encoding_to_correct_delay_fus 1.10862281 7.363016e+00 0.93118834
## correct_enc_to_delay_fus_high_corr 2.26857790 1.813958e-01 5.56199360
## enc_to_correct_delay_fus_high_corr 0.35469393 9.066755e-01 0.58363490
## high_corr_DFR_enc 8.97707657 1.324317e+01 3.53725516
## high_corr_DFR_delay 6.97360439 7.731825e+00 9.15856319
## high_incorr_DFR_enc 11.37968411 1.533967e+00 3.53373257
## high_incorr_DFR_del 1.16275433 3.108101e+01 0.04307172
## low_corr_DFR_enc 0.01907267 3.873799e+00 21.47418977
## low_corr_DFR_del 10.93665468 6.895772e+00 18.93833978
## correct_encoding_to_correct_delay_DFR 0.71502757 5.525206e-02 0.23406910
## correct_enc_to_delay_DFR_high_corr 17.07614277 3.527081e+00 0.30173376
## enc_to_correct_delay_DFR_high_corr 7.35444149 5.643558e-04 0.02283145
## Dim.10 Dim.11 Dim.12
## high_corr_fus_enc 3.05826180 14.20359634 12.79432679
## high_corr_fus_delay 3.01058013 11.00588766 0.11489680
## high_incorr_fus_enc 21.99835442 12.29094893 1.26422213
## high_incorr_fus_del 15.10088094 12.12088013 2.26802051
## low_corr_fus_enc 2.69663818 0.08395394 13.50443179
## low_corr_fus_del 5.06737616 0.58701359 3.51583246
## correct_encoding_to_correct_delay_fus 4.48867946 1.44374888 15.00377887
## correct_enc_to_delay_fus_high_corr 0.21204064 6.99009127 0.04402601
## enc_to_correct_delay_fus_high_corr 0.66837099 3.28232572 8.50362100
## high_corr_DFR_enc 0.75913583 2.30381084 2.71375016
## high_corr_DFR_delay 0.02687276 7.78441426 4.19283372
## high_incorr_DFR_enc 0.37644504 25.81909571 0.82029360
## high_incorr_DFR_del 7.70508883 0.09216770 4.20948924
## low_corr_DFR_enc 17.99784089 0.17885629 1.78360032
## low_corr_DFR_del 0.05765233 0.13171171 0.13406784
## correct_encoding_to_correct_delay_DFR 1.37219581 0.39066736 13.45204520
## correct_enc_to_delay_DFR_high_corr 10.15222813 0.60126720 14.86826144
## enc_to_correct_delay_DFR_high_corr 5.25135766 0.68956248 0.81250212
## Dim.13 Dim.14 Dim.15
## high_corr_fus_enc 2.33647746 5.668909126 13.230119858
## high_corr_fus_delay 0.29702653 14.516471569 0.010833283
## high_incorr_fus_enc 4.54712637 2.837175510 0.733115248
## high_incorr_fus_del 0.71986528 1.119258587 0.023833327
## low_corr_fus_enc 10.47781220 3.909815194 6.401375424
## low_corr_fus_del 7.18681532 35.841990642 2.136589194
## correct_encoding_to_correct_delay_fus 0.01309315 3.054845032 0.152938920
## correct_enc_to_delay_fus_high_corr 3.51328335 4.155480928 0.253602543
## enc_to_correct_delay_fus_high_corr 0.03253355 0.161433857 2.483352819
## high_corr_DFR_enc 0.21342871 0.224401718 0.857228558
## high_corr_DFR_delay 0.77269834 0.001275598 13.275335430
## high_incorr_DFR_enc 2.74604035 15.839816897 0.097842766
## high_incorr_DFR_del 1.99347123 3.389326637 0.001084256
## low_corr_DFR_enc 15.67885249 0.243554929 1.302385149
## low_corr_DFR_del 23.87412401 2.080946377 1.644831191
## correct_encoding_to_correct_delay_DFR 5.83926371 0.188322627 30.081050300
## correct_enc_to_delay_DFR_high_corr 11.40170826 4.098345795 0.092591689
## enc_to_correct_delay_DFR_high_corr 8.35637969 2.668628978 27.221890046
## Dim.16 Dim.17 Dim.18
## high_corr_fus_enc 8.20871521 0.23416436 10.62976630
## high_corr_fus_delay 7.86013378 6.06078104 10.86516359
## high_incorr_fus_enc 4.85482824 0.06730919 0.10684326
## high_incorr_fus_del 0.49738437 1.06889057 0.05589937
## low_corr_fus_enc 1.01490697 1.13750071 0.72076556
## low_corr_fus_del 4.29784191 0.15871213 2.42084858
## correct_encoding_to_correct_delay_fus 7.14161383 25.05638937 0.06441586
## correct_enc_to_delay_fus_high_corr 10.99942711 6.64369787 28.97610919
## enc_to_correct_delay_fus_high_corr 0.07137790 18.83193792 32.63304480
## high_corr_DFR_enc 31.88189668 10.54965790 4.12863183
## high_corr_DFR_delay 2.39821972 8.06594445 1.64332538
## high_incorr_DFR_enc 13.74731896 0.20811871 0.61590673
## high_incorr_DFR_del 3.96282252 2.89813498 0.13447509
## low_corr_DFR_enc 1.01735499 0.17216382 0.00986559
## low_corr_DFR_del 0.11457437 0.12383570 0.38775820
## correct_encoding_to_correct_delay_DFR 0.02673421 10.11043396 0.75033540
## correct_enc_to_delay_DFR_high_corr 0.98918827 4.71355567 1.63853413
## enc_to_correct_delay_DFR_high_corr 0.91566095 3.89877164 4.21831114
for (axis in seq.int(1,5)){
print(fviz_contrib(res_sim.pca, choice = "var", axes = axis, top = 10))
}
fviz_pca_var(res_sim.pca,
col.var = "contrib", # Color by contributions to the PC
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE # Avoid text overlapping
)
Now, let’s do the same for the MVPA measures. We end up needing 12 PCs to reflect 75% of the variance.
PC1: Fusiform during encoding and probe PC2: DFR during encoding PC3: DFR during probe, averages from template across trial type PC4: Delay period decoding PC5: Fusiform encoding during template PC6: Individual trials in fusiform, mostly during delay PC7: Individual trials, low correct and high incorrect PC8: High incorrect DFR across entire trial from individual trials PC9: DFR decoding during correct trials in encoding and probe PC10: Correct averaged from template trials during delay and probe PC11: Low correct trials, mostly delay period PC12: Mostly correct trials from templates in the fusiform
res_MVPA.pca <- prcomp(data_for_reg[,c(57:92)], scale = TRUE)
fviz_eig(res_MVPA.pca)
summary(res_MVPA.pca)
## Importance of components:
## PC1 PC2 PC3 PC4 PC5 PC6 PC7
## Standard deviation 2.1575 1.9266 1.84175 1.68366 1.59799 1.56683 1.21421
## Proportion of Variance 0.1293 0.1031 0.09422 0.07874 0.07093 0.06819 0.04095
## Cumulative Proportion 0.1293 0.2324 0.32663 0.40537 0.47630 0.54450 0.58545
## PC8 PC9 PC10 PC11 PC12 PC13 PC14
## Standard deviation 1.14888 1.08102 1.04333 1.00443 0.95488 0.93740 0.92004
## Proportion of Variance 0.03666 0.03246 0.03024 0.02802 0.02533 0.02441 0.02351
## Cumulative Proportion 0.62211 0.65457 0.68481 0.71284 0.73816 0.76257 0.78609
## PC15 PC16 PC17 PC18 PC19 PC20 PC21
## Standard deviation 0.84687 0.81679 0.79631 0.75825 0.72385 0.6971 0.68002
## Proportion of Variance 0.01992 0.01853 0.01761 0.01597 0.01455 0.0135 0.01285
## Cumulative Proportion 0.80601 0.82454 0.84215 0.85812 0.87268 0.8862 0.89902
## PC22 PC23 PC24 PC25 PC26 PC27 PC28
## Standard deviation 0.6434 0.6236 0.61003 0.59364 0.57402 0.56315 0.50385
## Proportion of Variance 0.0115 0.0108 0.01034 0.00979 0.00915 0.00881 0.00705
## Cumulative Proportion 0.9105 0.9213 0.93166 0.94145 0.95060 0.95941 0.96646
## PC29 PC30 PC31 PC32 PC33 PC34 PC35
## Standard deviation 0.4723 0.43151 0.41615 0.37341 0.37014 0.36314 0.34177
## Proportion of Variance 0.0062 0.00517 0.00481 0.00387 0.00381 0.00366 0.00324
## Cumulative Proportion 0.9727 0.97783 0.98264 0.98651 0.99032 0.99398 0.99723
## PC36
## Standard deviation 0.31598
## Proportion of Variance 0.00277
## Cumulative Proportion 1.00000
res_MVPA.var <- get_pca_var(res_MVPA.pca)
#res_MVPA.var$contrib # Contributions to the PCs
for (axis in seq.int(1,12)){
print(fviz_contrib(res_MVPA.pca, choice = "var", axes = axis, top = 10))
}
fviz_pca_var(res_MVPA.pca,
col.var = "contrib", # Color by contributions to the PC
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE # Avoid text overlapping
)
For the structural data, we see that 20 PCs are necessary to explain 75% of the variance. There was a lot of overlap in these, so it was kind of tough to describe/classify them
PC1: Parietal lobe structures PC2: FA measures PC3: subcortical; cerebellum, hippocampus PC4: Cuneus, pericalcarine, superior parietal, lingual PC5: Temporal pole, entorhinal PC6: Pericalcarine, lateral occipital PC7: corpus callosum, caudate PC8: Temporal, parahippocampal, FA PC9: Frontal pole, corpus callosum and corpus callosum PC10: Cerebellum, frontal PC11: Corpus callosum, cerebellum, cingulum/HPC connection PC12: Parahippocampal and lateral occipital PC13: L HPC, HPC/cingulum connection PC14: corticospinal tract, cingulum, pars triangularis PC15: caudal anterior cingulate, transverse temporal PC16: Accumbens, HPC PC17: subcortical structures PC18: Cingulate, subcortical PC19: lateral orbitofrontal poles PC20: Longitudinal fasciculus
res_struct.pca <- prcomp(struc_df[,c(4:37, 40:116)], scale = TRUE)
fviz_eig(res_struct.pca)
summary(res_struct.pca)
## Importance of components:
## PC1 PC2 PC3 PC4 PC5 PC6 PC7
## Standard deviation 4.8575 3.4360 2.94908 2.4529 2.0129 1.80861 1.70963
## Proportion of Variance 0.2126 0.1064 0.07835 0.0542 0.0365 0.02947 0.02633
## Cumulative Proportion 0.2126 0.3189 0.39729 0.4515 0.4880 0.51747 0.54380
## PC8 PC9 PC10 PC11 PC12 PC13 PC14
## Standard deviation 1.60028 1.53933 1.44424 1.4094 1.31808 1.28480 1.27019
## Proportion of Variance 0.02307 0.02135 0.01879 0.0179 0.01565 0.01487 0.01453
## Cumulative Proportion 0.56687 0.58822 0.60701 0.6249 0.64056 0.65543 0.66996
## PC15 PC16 PC17 PC18 PC19 PC20 PC21
## Standard deviation 1.22009 1.18939 1.17411 1.15538 1.12576 1.08834 1.06980
## Proportion of Variance 0.01341 0.01274 0.01242 0.01203 0.01142 0.01067 0.01031
## Cumulative Proportion 0.68337 0.69612 0.70854 0.72056 0.73198 0.74265 0.75296
## PC22 PC23 PC24 PC25 PC26 PC27 PC28
## Standard deviation 1.04663 1.01372 0.99807 0.9713 0.93578 0.9243 0.91814
## Proportion of Variance 0.00987 0.00926 0.00897 0.0085 0.00789 0.0077 0.00759
## Cumulative Proportion 0.76283 0.77209 0.78106 0.7896 0.79745 0.8052 0.81274
## PC29 PC30 PC31 PC32 PC33 PC34 PC35
## Standard deviation 0.90060 0.87579 0.86728 0.84653 0.83172 0.82782 0.81154
## Proportion of Variance 0.00731 0.00691 0.00678 0.00646 0.00623 0.00617 0.00593
## Cumulative Proportion 0.82005 0.82696 0.83374 0.84019 0.84642 0.85260 0.85853
## PC36 PC37 PC38 PC39 PC40 PC41 PC42
## Standard deviation 0.79091 0.77756 0.7446 0.73994 0.73212 0.71680 0.70169
## Proportion of Variance 0.00564 0.00545 0.0050 0.00493 0.00483 0.00463 0.00444
## Cumulative Proportion 0.86417 0.86961 0.8746 0.87954 0.88437 0.88900 0.89343
## PC43 PC44 PC45 PC46 PC47 PC48 PC49
## Standard deviation 0.68762 0.68567 0.68061 0.6665 0.65410 0.63940 0.63020
## Proportion of Variance 0.00426 0.00424 0.00417 0.0040 0.00385 0.00368 0.00358
## Cumulative Proportion 0.89769 0.90193 0.90610 0.9101 0.91396 0.91764 0.92122
## PC50 PC51 PC52 PC53 PC54 PC55 PC56
## Standard deviation 0.61892 0.61229 0.60224 0.59724 0.57329 0.56124 0.5573
## Proportion of Variance 0.00345 0.00338 0.00327 0.00321 0.00296 0.00284 0.0028
## Cumulative Proportion 0.92467 0.92805 0.93132 0.93453 0.93749 0.94033 0.9431
## PC57 PC58 PC59 PC60 PC61 PC62 PC63
## Standard deviation 0.54948 0.53962 0.53504 0.52181 0.51003 0.49703 0.48417
## Proportion of Variance 0.00272 0.00262 0.00258 0.00245 0.00234 0.00223 0.00211
## Cumulative Proportion 0.94585 0.94847 0.95105 0.95350 0.95585 0.95807 0.96018
## PC64 PC65 PC66 PC67 PC68 PC69 PC70
## Standard deviation 0.47581 0.4598 0.45103 0.4464 0.44420 0.4344 0.42001
## Proportion of Variance 0.00204 0.0019 0.00183 0.0018 0.00178 0.0017 0.00159
## Cumulative Proportion 0.96222 0.9641 0.96596 0.9677 0.96953 0.9712 0.97282
## PC71 PC72 PC73 PC74 PC75 PC76 PC77
## Standard deviation 0.41408 0.40205 0.39176 0.38781 0.37340 0.37006 0.35839
## Proportion of Variance 0.00154 0.00146 0.00138 0.00135 0.00126 0.00123 0.00116
## Cumulative Proportion 0.97437 0.97582 0.97720 0.97856 0.97982 0.98105 0.98221
## PC78 PC79 PC80 PC81 PC82 PC83 PC84
## Standard deviation 0.35273 0.34312 0.3328 0.33142 0.32256 0.31218 0.30351
## Proportion of Variance 0.00112 0.00106 0.0010 0.00099 0.00094 0.00088 0.00083
## Cumulative Proportion 0.98333 0.98439 0.9854 0.98638 0.98731 0.98819 0.98902
## PC85 PC86 PC87 PC88 PC89 PC90 PC91
## Standard deviation 0.30151 0.29521 0.29215 0.28269 0.27484 0.26352 0.25229
## Proportion of Variance 0.00082 0.00079 0.00077 0.00072 0.00068 0.00063 0.00057
## Cumulative Proportion 0.98984 0.99063 0.99139 0.99211 0.99279 0.99342 0.99399
## PC92 PC93 PC94 PC95 PC96 PC97 PC98
## Standard deviation 0.24645 0.23752 0.23148 0.22418 0.22205 0.20897 0.20604
## Proportion of Variance 0.00055 0.00051 0.00048 0.00045 0.00044 0.00039 0.00038
## Cumulative Proportion 0.99454 0.99505 0.99553 0.99598 0.99643 0.99682 0.99720
## PC99 PC100 PC101 PC102 PC103 PC104 PC105
## Standard deviation 0.19572 0.18983 0.18655 0.17380 0.16814 0.16283 0.15889
## Proportion of Variance 0.00035 0.00032 0.00031 0.00027 0.00025 0.00024 0.00023
## Cumulative Proportion 0.99755 0.99787 0.99819 0.99846 0.99871 0.99895 0.99918
## PC106 PC107 PC108 PC109 PC110 PC111
## Standard deviation 0.15145 0.13058 0.12513 0.11639 0.11454 0.09280
## Proportion of Variance 0.00021 0.00015 0.00014 0.00012 0.00012 0.00008
## Cumulative Proportion 0.99939 0.99954 0.99968 0.99980 0.99992 1.00000
res_struct.var <- get_pca_var(res_struct.pca)
for (axis in seq.int(1,20)){
print(fviz_contrib(res_struct.pca, choice = "var", axes = axis, top = 10))
}
fviz_pca_var(res_struct.pca,
col.var = "contrib", # Color by contributions to the PC
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE # Avoid text overlapping
)
For the EEG data, we see that 13 PCs are necessary to explain 75% of the variance.
PC1: Alpha and beta at high load during probe PC2: ERSPs at probe during low load trials; specifically, low gamma
PC3: Alpha power at delay, beta during cue PC4: Low gamma PC5: Theta power PC6: N170 amplitude and high load Oz power across frequency band PC7: P3, n170 amplitude; low gamma PC8: Low gamma in mid occipital component PC9: P3 component PC10: CDA - 1 dot condition PC11: Oz at low load, mid occipital at high load PC12: CDA - 5 dot condition; low gamma power PC13: CDA - 3 dot condition; cue N170 amplitude, mid occipital theta power at high load
res_EEG.pca <- prcomp(EEG_df[complete.cases(EEG_df),2:90], scale = TRUE)
fviz_eig(res_EEG.pca)
summary(res_EEG.pca)
## Importance of components:
## PC1 PC2 PC3 PC4 PC5 PC6 PC7
## Standard deviation 4.0630 3.0758 2.5853 2.40114 2.15029 2.08363 1.95699
## Proportion of Variance 0.1855 0.1063 0.0751 0.06478 0.05195 0.04878 0.04303
## Cumulative Proportion 0.1855 0.2918 0.3669 0.43165 0.48361 0.53239 0.57542
## PC8 PC9 PC10 PC11 PC12 PC13 PC14
## Standard deviation 1.80774 1.66088 1.59428 1.54072 1.41986 1.39163 1.32552
## Proportion of Variance 0.03672 0.03099 0.02856 0.02667 0.02265 0.02176 0.01974
## Cumulative Proportion 0.61214 0.64313 0.67169 0.69836 0.72101 0.74277 0.76252
## PC15 PC16 PC17 PC18 PC19 PC20 PC21
## Standard deviation 1.28585 1.22508 1.193 1.11679 1.09992 1.02772 0.9760
## Proportion of Variance 0.01858 0.01686 0.016 0.01401 0.01359 0.01187 0.0107
## Cumulative Proportion 0.78109 0.79796 0.814 0.82797 0.84156 0.85343 0.8641
## PC22 PC23 PC24 PC25 PC26 PC27 PC28
## Standard deviation 0.9528 0.93602 0.84784 0.81958 0.80495 0.77450 0.74009
## Proportion of Variance 0.0102 0.00984 0.00808 0.00755 0.00728 0.00674 0.00615
## Cumulative Proportion 0.8743 0.88418 0.89226 0.89980 0.90708 0.91382 0.91998
## PC29 PC30 PC31 PC32 PC33 PC34 PC35
## Standard deviation 0.73342 0.72142 0.6673 0.6325 0.61799 0.58731 0.56147
## Proportion of Variance 0.00604 0.00585 0.0050 0.0045 0.00429 0.00388 0.00354
## Cumulative Proportion 0.92602 0.93187 0.9369 0.9414 0.94566 0.94953 0.95308
## PC36 PC37 PC38 PC39 PC40 PC41 PC42
## Standard deviation 0.55524 0.5249 0.50407 0.48463 0.46445 0.4523 0.4429
## Proportion of Variance 0.00346 0.0031 0.00285 0.00264 0.00242 0.0023 0.0022
## Cumulative Proportion 0.95654 0.9596 0.96249 0.96513 0.96755 0.9698 0.9721
## PC43 PC44 PC45 PC46 PC47 PC48 PC49
## Standard deviation 0.43482 0.41472 0.40240 0.39644 0.37918 0.36401 0.34795
## Proportion of Variance 0.00212 0.00193 0.00182 0.00177 0.00162 0.00149 0.00136
## Cumulative Proportion 0.97418 0.97611 0.97793 0.97970 0.98131 0.98280 0.98416
## PC50 PC51 PC52 PC53 PC54 PC55 PC56
## Standard deviation 0.34289 0.32595 0.3125 0.30052 0.29226 0.28142 0.26896
## Proportion of Variance 0.00132 0.00119 0.0011 0.00101 0.00096 0.00089 0.00081
## Cumulative Proportion 0.98548 0.98668 0.9878 0.98879 0.98975 0.99064 0.99145
## PC57 PC58 PC59 PC60 PC61 PC62 PC63
## Standard deviation 0.25955 0.25181 0.24440 0.24017 0.22853 0.22106 0.20406
## Proportion of Variance 0.00076 0.00071 0.00067 0.00065 0.00059 0.00055 0.00047
## Cumulative Proportion 0.99221 0.99292 0.99359 0.99424 0.99483 0.99538 0.99585
## PC64 PC65 PC66 PC67 PC68 PC69 PC70
## Standard deviation 0.19535 0.1877 0.18662 0.17377 0.17313 0.15105 0.14366
## Proportion of Variance 0.00043 0.0004 0.00039 0.00034 0.00034 0.00026 0.00023
## Cumulative Proportion 0.99627 0.9967 0.99706 0.99740 0.99774 0.99799 0.99823
## PC71 PC72 PC73 PC74 PC75 PC76 PC77
## Standard deviation 0.13985 0.13650 0.1325 0.12264 0.10828 0.10774 0.10214
## Proportion of Variance 0.00022 0.00021 0.0002 0.00017 0.00013 0.00013 0.00012
## Cumulative Proportion 0.99845 0.99865 0.9989 0.99902 0.99915 0.99928 0.99940
## PC78 PC79 PC80 PC81 PC82 PC83 PC84
## Standard deviation 0.09911 0.09505 0.09079 0.08006 0.07440 0.07230 0.06224
## Proportion of Variance 0.00011 0.00010 0.00009 0.00007 0.00006 0.00006 0.00004
## Cumulative Proportion 0.99951 0.99961 0.99970 0.99978 0.99984 0.99990 0.99994
## PC85 PC86 PC87 PC88 PC89
## Standard deviation 0.05813 0.04298 1.388e-07 1.235e-07 9.143e-08
## Proportion of Variance 0.00004 0.00002 0.000e+00 0.000e+00 0.000e+00
## Cumulative Proportion 0.99998 1.00000 1.000e+00 1.000e+00 1.000e+00
res_EEG.var <- get_pca_var(res_EEG.pca)
for (axis in seq.int(1,13)){
print(fviz_contrib(res_EEG.pca, choice = "var", axes = axis, top = 10))
}
fviz_pca_var(res_EEG.pca,
col.var = "contrib", # Color by contributions to the PC
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE # Avoid text overlapping
)
For the resting state data, we see that 8 PCs are necessary to explain 75% of the variance.
PC1: Participation coefficients across network (both average and individual network) PC2: FPCN connectivity with other networks, within connectivity for DMN and DAN PC3: Within connectivity for DMN, FPCN connectivity with visual, CO, DMN, DANA networks PC4: Global efficiency, within CO connectivity, participation coefficients PC5: Within visual connectivity and participation coefficient, within CO connectivity PC6: Louvain modularity, within DAN connectivity PC7: Within network VAN connectivity PC8: Global efficiency, FPCN connectivity with DMN, FPCN and DAN, VAN intranetwork connectivity
res_RS.pca <- prcomp(RS_df[complete.cases(RS_df),2:21], scale = TRUE)
fviz_eig(res_RS.pca)
summary(res_RS.pca)
## Importance of components:
## PC1 PC2 PC3 PC4 PC5 PC6 PC7
## Standard deviation 2.1445 2.0285 1.29812 1.13191 1.04771 0.98921 0.94066
## Proportion of Variance 0.2299 0.2057 0.08426 0.06406 0.05489 0.04893 0.04424
## Cumulative Proportion 0.2299 0.4357 0.51995 0.58401 0.63890 0.68783 0.73207
## PC8 PC9 PC10 PC11 PC12 PC13 PC14
## Standard deviation 0.90541 0.84708 0.8087 0.76047 0.75206 0.68202 0.60154
## Proportion of Variance 0.04099 0.03588 0.0327 0.02892 0.02828 0.02326 0.01809
## Cumulative Proportion 0.77306 0.80893 0.8416 0.87055 0.89883 0.92209 0.94018
## PC15 PC16 PC17 PC18 PC19 PC20
## Standard deviation 0.5745 0.50112 0.46856 0.41335 0.39669 0.25988
## Proportion of Variance 0.0165 0.01256 0.01098 0.00854 0.00787 0.00338
## Cumulative Proportion 0.9567 0.96923 0.98021 0.98875 0.99662 1.00000
res_RS.var <- get_pca_var(res_RS.pca)
for (axis in seq.int(1,8)){
print(fviz_contrib(res_RS.pca, choice = "var", axes = axis, top = 10))
}
fviz_pca_var(res_RS.pca,
col.var = "contrib", # Color by contributions to the PC
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE # Avoid text overlapping
)
Now that we have our PCs to reduce overlapping variance, we can use these in a series of regressions to predict span, BPRS and accuracy at high load. We will use a number of different methods to select features: stepwise regression, ridge regression, LASSO regression and ElasticNet regression. A brief description of the methods are as follows:
Stepwise Regression: Initially takes all parameters and sequentially removes parameters to minimize the AIC of the model overall. At each step, it calculates what the AIC would be if it removed each individual parameter and then removes the one that makes the most difference. Stops when model converges at a minimal AIC.
Ridge Regression: A type of penalized linear regression (uses L2 norm - minimizes the sum of the squared coefficients). Shrinks the values of unimportant coefficients close to zero, but does not remove them.
LASSO Regression: Another type of penalized linear regression (uses L1 norm - minimizes the sum of the absolute value of the coefficients). Forces coefficients that are unimportant to the model to be zero, creating a sparse model.
ElasticNet Regression: Uses both L1- and L2-norm penalties with regression, so shrinks some coefficients close to zero and some to exactly zero.
If we compare the 3 models that perform feature selection, the following PCs show up in all 3 of them:
It seems as though these are particularly weighted towards encoding and regions associated with visual processing. Structural seems to show some HPC involvement. While accuracy seems to be only weighted towards visual components, predicting span also includes measures at low load, from the delay period, and all modalities.
reg_data <- data.frame(PTID = constructs_fMRI$PTID,
span = data_for_reg$span,
high_acc = data_for_reg$high_acc,
BPRS = data_for_reg$BPRS)
univ_PCs <- data.frame(PTID = constructs_fMRI$PTID[!is.na(data_for_reg$L_CUE_LE)], res.pca[["x"]][,1:3])
colnames(univ_PCs)[2:4] <- paste("PC",c(1:3),"_univ",sep="")
sim_PCs <- data.frame(PTID = constructs_fMRI$PTID, res_sim.pca[["x"]][,1:5])
colnames(sim_PCs)[2:6] <- paste("PC",c(1:5),"_sim",sep="")
MVPA_PCs <- data.frame(PTID = constructs_fMRI$PTID, res_MVPA.pca[["x"]][,1:12])
colnames(MVPA_PCs)[2:13] <- paste("PC",c(1:12),"_MVPA",sep="")
EEG_PCs <- data.frame(PTID = EEG_df$PTID[complete.cases(EEG_df)], res_EEG.pca[["x"]][,1:13])
colnames(EEG_PCs)[2:14] <- paste("PC",c(1:13),"_EEG",sep="")
RS_PCs <- data.frame(PTID = RS_df$PTID, res_RS.pca[["x"]][,1:8])
colnames(RS_PCs)[2:9] <- paste("PC",c(1:8),"_RS",sep="")
struc_PCs <- data.frame(PTID=struc_df$ID, res_struct.pca[["x"]][,1:20])
colnames(struc_PCs)[2:21] <- paste("PC",c(1:20),"_struc",sep="")
reg_data <- Reduce(function(x,y) merge(x=x, y=y, by = "PTID", all.x = TRUE),
list(reg_data, univ_PCs, sim_PCs, MVPA_PCs, EEG_PCs, RS_PCs, struc_PCs))
#add scanner, age, gender (won't include CS/NCS in regression)
reg_data <- merge(reg_data, p200_demographics, by = "PTID")
set.seed(123)
training.samples_span <- reg_data$span %>%
createDataPartition(p = 0.8, list = FALSE)
train.data_span <- reg_data[training.samples_span, c(2, 5:68)]
train.data_span.impute <- preProcess(train.data_span, method="knnImpute")
train.data_span <- predict(train.data_span.impute, train.data_span)
test.data_span <- reg_data[-training.samples_span, c(2, 5:68)]
# standardize, because that is important for ridge regression
test.data_span <- sapply(test.data_span, scale)
test.data_span <- data.frame(test.data_span)
lambda <- 10^seq(-3, 3, length = 100)
While the final stepwise model is significant overall, we see significant effects of:
step.span <- train(span ~., data = train.data_span,
method = "lmStepAIC",
trControl = trainControl("cv", number = 10, savePredictions = "all"),
trace = FALSE
)
# Model accuracy
step.span$results
## parameter RMSE Rsquared MAE RMSESD RsquaredSD MAESD
## 1 none 1.074224 0.2174097 0.8658311 0.2729562 0.07059115 0.2288917
predictions.step.span <- step.span %>% predict(test.data_span)
# Final model coefficients
step.span$finalModel
##
## Call:
## lm(formula = .outcome ~ PC1_univ + PC3_univ + PC1_sim + PC4_sim +
## PC1_MVPA + PC8_MVPA + PC11_MVPA + PC12_MVPA + PC2_EEG + PC5_EEG +
## PC6_EEG + PC8_EEG + PC9_EEG + PC10_EEG + PC11_EEG + PC1_RS +
## PC4_RS + PC6_RS + PC8_RS + PC1_struc + PC5_struc + PC6_struc +
## PC7_struc + PC8_struc + PC11_struc + PC13_struc + PC16_struc +
## PC20_struc + GENDER + AGE, data = dat)
##
## Coefficients:
## (Intercept) PC1_univ PC3_univ PC1_sim PC4_sim PC1_MVPA
## -0.007144 0.188708 -0.147683 -0.224024 -0.114458 -0.113840
## PC8_MVPA PC11_MVPA PC12_MVPA PC2_EEG PC5_EEG PC6_EEG
## 0.147537 -0.254476 -0.176782 0.177508 -0.183209 -0.148509
## PC8_EEG PC9_EEG PC10_EEG PC11_EEG PC1_RS PC4_RS
## 0.173004 0.203781 0.193644 -0.209794 -0.174313 -0.102554
## PC6_RS PC8_RS PC1_struc PC5_struc PC6_struc PC7_struc
## -0.136497 0.162936 0.147089 -0.117982 0.137407 -0.132747
## PC8_struc PC11_struc PC13_struc PC16_struc PC20_struc GENDER
## -0.101449 -0.155168 -0.173257 -0.098792 -0.180788 -0.296447
## AGE
## -0.180486
# Summary of the model
summary(step.span$finalModel)
##
## Call:
## lm(formula = .outcome ~ PC1_univ + PC3_univ + PC1_sim + PC4_sim +
## PC1_MVPA + PC8_MVPA + PC11_MVPA + PC12_MVPA + PC2_EEG + PC5_EEG +
## PC6_EEG + PC8_EEG + PC9_EEG + PC10_EEG + PC11_EEG + PC1_RS +
## PC4_RS + PC6_RS + PC8_RS + PC1_struc + PC5_struc + PC6_struc +
## PC7_struc + PC8_struc + PC11_struc + PC13_struc + PC16_struc +
## PC20_struc + GENDER + AGE, data = dat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.51284 -0.34827 -0.01981 0.31977 1.34064
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.007144 0.057212 -0.125 0.900857
## PC1_univ 0.188708 0.069968 2.697 0.008128 **
## PC3_univ -0.147683 0.064669 -2.284 0.024366 *
## PC1_sim -0.224024 0.073117 -3.064 0.002765 **
## PC4_sim -0.114458 0.065000 -1.761 0.081114 .
## PC1_MVPA -0.113840 0.066077 -1.723 0.087809 .
## PC8_MVPA 0.147537 0.067692 2.180 0.031485 *
## PC11_MVPA -0.254476 0.068644 -3.707 0.000334 ***
## PC12_MVPA -0.176782 0.065971 -2.680 0.008534 **
## PC2_EEG 0.177508 0.070700 2.511 0.013544 *
## PC5_EEG -0.183209 0.070887 -2.585 0.011099 *
## PC6_EEG -0.148509 0.073016 -2.034 0.044434 *
## PC8_EEG 0.173004 0.069169 2.501 0.013894 *
## PC9_EEG 0.203781 0.076161 2.676 0.008631 **
## PC10_EEG 0.193644 0.070431 2.749 0.007010 **
## PC11_EEG -0.209794 0.066857 -3.138 0.002198 **
## PC1_RS -0.174313 0.065048 -2.680 0.008533 **
## PC4_RS -0.102554 0.064640 -1.587 0.115569
## PC6_RS -0.136497 0.065687 -2.078 0.040101 *
## PC8_RS 0.162936 0.069916 2.330 0.021658 *
## PC1_struc 0.147089 0.067838 2.168 0.032356 *
## PC5_struc -0.117982 0.075423 -1.564 0.120706
## PC6_struc 0.137407 0.062496 2.199 0.030055 *
## PC7_struc -0.132747 0.066242 -2.004 0.047601 *
## PC8_struc -0.101449 0.071019 -1.428 0.156066
## PC11_struc -0.155168 0.064337 -2.412 0.017577 *
## PC13_struc -0.173257 0.063944 -2.710 0.007849 **
## PC16_struc -0.098792 0.063449 -1.557 0.122417
## PC20_struc -0.180788 0.064972 -2.783 0.006377 **
## GENDER -0.296447 0.069994 -4.235 4.85e-05 ***
## AGE -0.180486 0.078618 -2.296 0.023639 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.6715 on 107 degrees of freedom
## Multiple R-squared: 0.6478, Adjusted R-squared: 0.549
## F-statistic: 6.56 on 30 and 107 DF, p-value: 1.657e-13
Rsquared_step.span <- calc_r_squared(step.span, predictions.step.span, test.data_span$span)
## Warning in cbind(preds, obs): number of rows of result is not a multiple of
## vector length (arg 1)
ridge.span <- train(
span ~., data = train.data_span, method = "glmnet",
trControl = trainControl("cv", number = 10, savePredictions = "all"),
tuneGrid = expand.grid(alpha = 0, lambda = lambda)
)
## Warning in nominalTrainWorkflow(x = x, y = y, wts = weights, info = trainInfo, :
## There were missing values in resampled performance measures.
# Model coefficients
coef(ridge.span$finalModel, ridge.span$bestTune$lambda)
## 65 x 1 sparse Matrix of class "dgCMatrix"
## 1
## (Intercept) -0.0033917897
## PC1_univ 0.1340107768
## PC2_univ -0.0219767100
## PC3_univ -0.0948913299
## PC1_sim -0.1327639281
## PC2_sim 0.0492354661
## PC3_sim 0.0375248339
## PC4_sim -0.1058629318
## PC5_sim 0.0249874224
## PC1_MVPA -0.0761527175
## PC2_MVPA 0.0479719821
## PC3_MVPA -0.0005979921
## PC4_MVPA -0.0636231745
## PC5_MVPA 0.0611901452
## PC6_MVPA -0.0650211573
## PC7_MVPA 0.0566415257
## PC8_MVPA 0.0990820919
## PC9_MVPA 0.0135016323
## PC10_MVPA -0.0466438766
## PC11_MVPA -0.1658574607
## PC12_MVPA -0.1397123631
## PC1_EEG -0.0242227508
## PC2_EEG 0.1357899097
## PC3_EEG -0.0896947769
## PC4_EEG 0.0000497072
## PC5_EEG -0.1191717967
## PC6_EEG -0.1041427991
## PC7_EEG 0.0067642041
## PC8_EEG 0.1173030158
## PC9_EEG 0.1387645179
## PC10_EEG 0.1430414464
## PC11_EEG -0.1087693246
## PC12_EEG 0.0791667049
## PC13_EEG 0.0277235330
## PC1_RS -0.1022653348
## PC2_RS 0.0290814382
## PC3_RS 0.0123063280
## PC4_RS -0.0764798352
## PC5_RS -0.0666207079
## PC6_RS -0.1324977556
## PC7_RS -0.0058175214
## PC8_RS 0.0721582192
## PC1_struc 0.0506697922
## PC2_struc 0.0123712938
## PC3_struc -0.0024871761
## PC4_struc -0.0080711855
## PC5_struc -0.0352972867
## PC6_struc 0.0848525930
## PC7_struc -0.0819935066
## PC8_struc -0.0565604031
## PC9_struc -0.0496021299
## PC10_struc 0.0520280790
## PC11_struc -0.1053590975
## PC12_struc 0.0482599476
## PC13_struc -0.1921289772
## PC14_struc -0.0496700619
## PC15_struc -0.0066593606
## PC16_struc -0.1055194650
## PC17_struc -0.0273712807
## PC18_struc -0.0316196692
## PC19_struc -0.0287153312
## PC20_struc -0.1309214791
## GENDER -0.1877278162
## AGE -0.1074808682
## SCANNER -0.0711952018
# Make predictions
predictions.ridge.span <- ridge.span %>% predict(test.data_span)
# Model prediction performance
data.frame(
RMSE = RMSE(predictions.ridge.span, test.data_span$span),
Rsquare = calc_r_squared(ridge.span, predictions.ridge.span, test.data_span$span)
#Rsquare = R2(predictions.ridge.span, test.data_span$span)
)
## Warning in pred - obs: longer object length is not a multiple of shorter object
## length
## Warning in cbind(preds, obs): number of rows of result is not a multiple of
## vector length (arg 1)
## RMSE Rsquare
## 1 1.257204 0.1316746
In the LASSO regression, we see:
lasso.span <- train(
span ~., data = train.data_span, method = "glmnet",
trControl = trainControl("cv", number = 10, savePredictions = "all"),
tuneGrid = expand.grid(alpha = 1, lambda = lambda)
)
## Warning in nominalTrainWorkflow(x = x, y = y, wts = weights, info = trainInfo, :
## There were missing values in resampled performance measures.
# Model coefficients
coef(lasso.span$finalModel, lasso.span$bestTune$lambda)
## 65 x 1 sparse Matrix of class "dgCMatrix"
## 1
## (Intercept) -0.0009147192
## PC1_univ 0.1139975162
## PC2_univ .
## PC3_univ -0.0250836436
## PC1_sim -0.1227636177
## PC2_sim .
## PC3_sim .
## PC4_sim -0.0897125524
## PC5_sim .
## PC1_MVPA -0.0293030119
## PC2_MVPA 0.0032978368
## PC3_MVPA .
## PC4_MVPA -0.0106807052
## PC5_MVPA 0.0003474245
## PC6_MVPA -0.0164203362
## PC7_MVPA .
## PC8_MVPA 0.0904742057
## PC9_MVPA .
## PC10_MVPA -0.0226614115
## PC11_MVPA -0.1381743455
## PC12_MVPA -0.0886280112
## PC1_EEG .
## PC2_EEG 0.1461017648
## PC3_EEG -0.0521992894
## PC4_EEG .
## PC5_EEG -0.0531447566
## PC6_EEG -0.0009289607
## PC7_EEG .
## PC8_EEG 0.1119758165
## PC9_EEG 0.0925392333
## PC10_EEG 0.1375404459
## PC11_EEG -0.0835014177
## PC12_EEG 0.0267160408
## PC13_EEG .
## PC1_RS -0.0751297217
## PC2_RS .
## PC3_RS .
## PC4_RS -0.0419970098
## PC5_RS -0.0439283791
## PC6_RS -0.1287389372
## PC7_RS .
## PC8_RS .
## PC1_struc .
## PC2_struc .
## PC3_struc .
## PC4_struc .
## PC5_struc .
## PC6_struc 0.0615142785
## PC7_struc .
## PC8_struc -0.0047347627
## PC9_struc .
## PC10_struc 0.0214460283
## PC11_struc -0.1309274444
## PC12_struc 0.0188009162
## PC13_struc -0.1818564488
## PC14_struc .
## PC15_struc .
## PC16_struc -0.0556765789
## PC17_struc .
## PC18_struc .
## PC19_struc -0.0002880360
## PC20_struc -0.1457524862
## GENDER -0.1232796726
## AGE -0.0560491641
## SCANNER .
# Make predictions
predictions.lasso.span <- lasso.span %>% predict(test.data_span)
# Model prediction performance
data.frame(
RMSE = RMSE(predictions.lasso.span, test.data_span$span),
Rsquare = calc_r_squared(lasso.span, predictions.lasso.span, test.data_span$span)
)
## Warning in pred - obs: longer object length is not a multiple of shorter object
## length
## Warning in cbind(preds, obs): number of rows of result is not a multiple of
## vector length (arg 1)
## RMSE Rsquare
## 1 1.07252 0.06197683
elastic.span <- train(
span ~., data = train.data_span, method = "glmnet",
trControl = trainControl("cv", number = 10, savePredictions = "all"),
tuneLength = 10
)
# Model coefficients
coef(elastic.span$finalModel, elastic.span$bestTune$lambda)
## 65 x 1 sparse Matrix of class "dgCMatrix"
## 1
## (Intercept) -0.002390848
## PC1_univ 0.110735406
## PC2_univ .
## PC3_univ -0.056309249
## PC1_sim -0.113423654
## PC2_sim 0.020037733
## PC3_sim 0.003948348
## PC4_sim -0.093535828
## PC5_sim .
## PC1_MVPA -0.053393299
## PC2_MVPA 0.034908051
## PC3_MVPA .
## PC4_MVPA -0.038943009
## PC5_MVPA 0.036283765
## PC6_MVPA -0.042880643
## PC7_MVPA 0.027381619
## PC8_MVPA 0.083796203
## PC9_MVPA .
## PC10_MVPA -0.031727461
## PC11_MVPA -0.144467322
## PC12_MVPA -0.110379486
## PC1_EEG .
## PC2_EEG 0.140269634
## PC3_EEG -0.068095873
## PC4_EEG .
## PC5_EEG -0.084306528
## PC6_EEG -0.056035921
## PC7_EEG .
## PC8_EEG 0.108462195
## PC9_EEG 0.121536916
## PC10_EEG 0.132850744
## PC11_EEG -0.092894636
## PC12_EEG 0.051490737
## PC13_EEG 0.000353383
## PC1_RS -0.092255559
## PC2_RS .
## PC3_RS .
## PC4_RS -0.063053929
## PC5_RS -0.056765375
## PC6_RS -0.118270073
## PC7_RS .
## PC8_RS 0.033263754
## PC1_struc 0.011074842
## PC2_struc .
## PC3_struc .
## PC4_struc .
## PC5_struc -0.009016767
## PC6_struc 0.069776397
## PC7_struc -0.032856092
## PC8_struc -0.032977082
## PC9_struc -0.030340352
## PC10_struc 0.042708484
## PC11_struc -0.112947545
## PC12_struc 0.035100919
## PC13_struc -0.178030113
## PC14_struc -0.004451712
## PC15_struc .
## PC16_struc -0.085275356
## PC17_struc .
## PC18_struc -0.015742566
## PC19_struc -0.015782552
## PC20_struc -0.127685705
## GENDER -0.142534873
## AGE -0.073413373
## SCANNER -0.035871670
# Make predictions
predictions.elastic.span <- elastic.span %>% predict(test.data_span)
# Model prediction performance
data.frame(
RMSE = RMSE(predictions.elastic.span, test.data_span$span),
Rsquare = calc_r_squared(elastic.span, predictions.elastic.span, test.data_span$span)
)
## Warning in pred - obs: longer object length is not a multiple of shorter object
## length
## Warning in cbind(preds, obs): number of rows of result is not a multiple of
## vector length (arg 1)
## RMSE Rsquare
## 1 1.11816 0.1693417
When comparing models, ridge regression looks to be our best model - it explains 20% of the variance and the lowest error. Stepwise regression explains the same amount of variance, but has a higher RMSE.
models.span <- list(ridge = ridge.span, lasso = lasso.span, elastic = elastic.span, stepwise = step.span)
resamples(models.span) %>% summary( metric = "RMSE")
##
## Call:
## summary.resamples(object = ., metric = "RMSE")
##
## Models: ridge, lasso, elastic, stepwise
## Number of resamples: 10
##
## RMSE
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## ridge 0.7646023 0.8108598 0.8855973 0.8894753 0.9628334 1.040262 0
## lasso 0.7176100 0.7967754 0.8553695 0.9104562 1.0293614 1.163457 0
## elastic 0.6265120 0.7678263 0.9355636 0.8959385 1.0150169 1.087195 0
## stepwise 0.7823019 0.8978645 0.9928444 1.0742238 1.1531303 1.737915 0
resamples(models.span) %>% summary( metric = "Rsquared")
##
## Call:
## summary.resamples(object = ., metric = "Rsquared")
##
## Models: ridge, lasso, elastic, stepwise
## Number of resamples: 10
##
## Rsquared
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## ridge 0.0020774356 0.1378595 0.2885157 0.2481538 0.3139266 0.4793426 0
## lasso 0.0003324929 0.1147490 0.1583262 0.2129125 0.2496135 0.6735679 0
## elastic 0.0075399948 0.1142356 0.1767342 0.2055886 0.2563440 0.5712435 0
## stepwise 0.1112510146 0.1943181 0.2089696 0.2174097 0.2730964 0.3249919 0
If we look across models, the only things that are shared are:
set.seed(123)
training.samples_BPRS <- reg_data$BPRS %>%
createDataPartition(p = 0.8, list = FALSE)
train.data_BPRS <- reg_data[training.samples_BPRS, c(4, 5:68)]
train.data_BPRS.impute <- preProcess(train.data_BPRS, method="knnImpute")
train.data_BPRS <- predict(train.data_BPRS.impute, train.data_BPRS)
test.data_BPRS <- reg_data[-training.samples_BPRS, c(4, 5:68)]
# standardize, because that is important for ridge regression
test.data_BPRS <- sapply(test.data_BPRS, scale)
test.data_BPRS <- data.frame(test.data_BPRS)
lambda <- 10^seq(-3, 3, length = 100)
To predict BPRS, we see the PCs that contain important information are:
step.BPRS <- train(BPRS ~., data = train.data_BPRS,
method = "lmStepAIC",
trControl = trainControl("cv", number = 10, savePredictions = "all"),
trace = FALSE
)
# Model accuracy
step.BPRS$results
## parameter RMSE Rsquared MAE RMSESD RsquaredSD MAESD
## 1 none 1.13539 0.172732 0.9185089 0.2391299 0.2183835 0.1998057
# Final model coefficients
step.BPRS$finalModel
##
## Call:
## lm(formula = .outcome ~ PC2_univ + PC1_sim + PC5_sim + PC1_MVPA +
## PC5_MVPA + PC8_MVPA + PC9_MVPA + PC1_EEG + PC2_EEG + PC4_EEG +
## PC5_EEG + PC6_EEG + PC9_EEG + PC12_EEG + PC2_RS + PC4_RS +
## PC5_RS + PC2_struc + PC3_struc + PC4_struc + PC5_struc +
## PC6_struc + PC7_struc + PC10_struc + PC11_struc + PC12_struc +
## PC13_struc + PC14_struc + PC15_struc + AGE + SCANNER, data = dat)
##
## Coefficients:
## (Intercept) PC2_univ PC1_sim PC5_sim PC1_MVPA PC5_MVPA
## 0.006977 0.092691 0.210504 -0.119229 0.123232 -0.144720
## PC8_MVPA PC9_MVPA PC1_EEG PC2_EEG PC4_EEG PC5_EEG
## -0.112976 0.119367 0.213883 -0.102529 -0.128262 0.193908
## PC6_EEG PC9_EEG PC12_EEG PC2_RS PC4_RS PC5_RS
## 0.228683 -0.281747 -0.249332 -0.205166 0.124234 -0.180420
## PC2_struc PC3_struc PC4_struc PC5_struc PC6_struc PC7_struc
## 0.112888 0.134166 0.124608 -0.241359 -0.088955 -0.116247
## PC10_struc PC11_struc PC12_struc PC13_struc PC14_struc PC15_struc
## 0.123990 0.133473 0.110026 -0.140805 0.262936 0.098481
## AGE SCANNER
## 0.250839 -0.233065
# Summary of the model
summary(step.BPRS$finalModel)
##
## Call:
## lm(formula = .outcome ~ PC2_univ + PC1_sim + PC5_sim + PC1_MVPA +
## PC5_MVPA + PC8_MVPA + PC9_MVPA + PC1_EEG + PC2_EEG + PC4_EEG +
## PC5_EEG + PC6_EEG + PC9_EEG + PC12_EEG + PC2_RS + PC4_RS +
## PC5_RS + PC2_struc + PC3_struc + PC4_struc + PC5_struc +
## PC6_struc + PC7_struc + PC10_struc + PC11_struc + PC12_struc +
## PC13_struc + PC14_struc + PC15_struc + AGE + SCANNER, data = dat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.2134 -0.4318 0.0262 0.3782 1.8564
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.006977 0.058317 0.120 0.905002
## PC2_univ 0.092691 0.067979 1.364 0.175608
## PC1_sim 0.210504 0.072879 2.888 0.004695 **
## PC5_sim -0.119229 0.064655 -1.844 0.067965 .
## PC1_MVPA 0.123232 0.069473 1.774 0.078968 .
## PC5_MVPA -0.144720 0.065765 -2.201 0.029936 *
## PC8_MVPA -0.112976 0.069705 -1.621 0.108038
## PC9_MVPA 0.119367 0.064802 1.842 0.068270 .
## PC1_EEG 0.213883 0.069811 3.064 0.002772 **
## PC2_EEG -0.102529 0.068327 -1.501 0.136439
## PC4_EEG -0.128262 0.071052 -1.805 0.073884 .
## PC5_EEG 0.193908 0.070034 2.769 0.006643 **
## PC6_EEG 0.228683 0.069445 3.293 0.001348 **
## PC9_EEG -0.281747 0.071000 -3.968 0.000132 ***
## PC12_EEG -0.249332 0.071520 -3.486 0.000714 ***
## PC2_RS -0.205166 0.070635 -2.905 0.004476 **
## PC4_RS 0.124234 0.066518 1.868 0.064570 .
## PC5_RS -0.180420 0.068597 -2.630 0.009805 **
## PC2_struc 0.112888 0.067190 1.680 0.095874 .
## PC3_struc 0.134166 0.065490 2.049 0.042968 *
## PC4_struc 0.124608 0.063590 1.960 0.052674 .
## PC5_struc -0.241359 0.068830 -3.507 0.000667 ***
## PC6_struc -0.088955 0.067241 -1.323 0.188707
## PC7_struc -0.116247 0.062897 -1.848 0.067359 .
## PC10_struc 0.123990 0.064391 1.926 0.056835 .
## PC11_struc 0.133473 0.062617 2.132 0.035354 *
## PC12_struc 0.110026 0.064763 1.699 0.092272 .
## PC13_struc -0.140805 0.064633 -2.179 0.031583 *
## PC14_struc 0.262936 0.065368 4.022 0.000108 ***
## PC15_struc 0.098481 0.063366 1.554 0.123127
## AGE 0.250839 0.071943 3.487 0.000713 ***
## SCANNER -0.233065 0.072126 -3.231 0.001642 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.6843 on 106 degrees of freedom
## Multiple R-squared: 0.6377, Adjusted R-squared: 0.5318
## F-statistic: 6.019 on 31 and 106 DF, p-value: 1.544e-12
ridge.BPRS <- train(
BPRS ~., data = train.data_BPRS, method = "glmnet",
trControl = trainControl("cv", number = 10, savePredictions = "all"),
tuneGrid = expand.grid(alpha = 0, lambda = lambda)
)
## Warning in nominalTrainWorkflow(x = x, y = y, wts = weights, info = trainInfo, :
## There were missing values in resampled performance measures.
# Model coefficients
coef(ridge.BPRS$finalModel, ridge.BPRS$bestTune$lambda)
## 65 x 1 sparse Matrix of class "dgCMatrix"
## 1
## (Intercept) 0.0032072818
## PC1_univ -0.0029563597
## PC2_univ 0.0135727334
## PC3_univ 0.0384442107
## PC1_sim 0.0326084724
## PC2_sim 0.0161687503
## PC3_sim -0.0388119506
## PC4_sim 0.0002086321
## PC5_sim -0.0154784303
## PC1_MVPA 0.0201703900
## PC2_MVPA -0.0316333862
## PC3_MVPA 0.0129702445
## PC4_MVPA 0.0129239581
## PC5_MVPA -0.0326513900
## PC6_MVPA -0.0062823584
## PC7_MVPA -0.0320417223
## PC8_MVPA -0.0112354406
## PC9_MVPA 0.0248285814
## PC10_MVPA 0.0028135762
## PC11_MVPA 0.0169171822
## PC12_MVPA 0.0156852501
## PC1_EEG 0.0393990013
## PC2_EEG -0.0206545826
## PC3_EEG -0.0130389277
## PC4_EEG -0.0450054051
## PC5_EEG 0.0658064882
## PC6_EEG 0.0749178046
## PC7_EEG 0.0398848606
## PC8_EEG -0.0186645639
## PC9_EEG -0.0764089236
## PC10_EEG -0.0371411496
## PC11_EEG 0.0102346306
## PC12_EEG -0.0469452249
## PC13_EEG 0.0086907826
## PC1_RS -0.0161075471
## PC2_RS -0.0369350102
## PC3_RS -0.0284459739
## PC4_RS 0.0144379742
## PC5_RS -0.0464898193
## PC6_RS 0.0074823007
## PC7_RS 0.0065433627
## PC8_RS 0.0124530675
## PC1_struc 0.0148123633
## PC2_struc 0.0106125686
## PC3_struc 0.0374022360
## PC4_struc 0.0223285735
## PC5_struc -0.0271588311
## PC6_struc 0.0095995861
## PC7_struc -0.0364638429
## PC8_struc 0.0212187345
## PC9_struc 0.0244985266
## PC10_struc 0.0385076810
## PC11_struc 0.0413312733
## PC12_struc 0.0106479875
## PC13_struc -0.0091499150
## PC14_struc 0.0667056612
## PC15_struc 0.0199887616
## PC16_struc 0.0444868790
## PC17_struc -0.0011990441
## PC18_struc -0.0002558138
## PC19_struc -0.0165970854
## PC20_struc -0.0299908039
## GENDER 0.0058049611
## AGE 0.0384429713
## SCANNER -0.0723336232
# Make predictions
predictions.ridge.BPRS <- ridge.BPRS %>% predict(test.data_BPRS)
# Model prediction performance
data.frame(
RMSE = RMSE(predictions.ridge.BPRS, test.data_BPRS$BPRS),
#Rsquare = R2(predictions.ridge.BPRS, test.data_BPRS$BPRS)
Rsquare = calc_r_squared(ridge.BPRS, predictions.ridge.BPRS, test.data_BPRS$BPRS)
)
## Warning in pred - obs: longer object length is not a multiple of shorter object
## length
## Warning in cbind(preds, obs): number of rows of result is not a multiple of
## vector length (arg 1)
## RMSE Rsquare
## 1 0.9788575 0.0604822
LASSO gives us almost a combination of the above analyses:
lasso.BPRS <- train(
BPRS ~., data = train.data_BPRS, method = "glmnet",
trControl = trainControl("cv", number = 10, savePredictions = "all"),
tuneGrid = expand.grid(alpha = 1, lambda = lambda)
)
## Warning in nominalTrainWorkflow(x = x, y = y, wts = weights, info = trainInfo, :
## There were missing values in resampled performance measures.
# Model coefficients
coef(lasso.BPRS$finalModel, lasso.BPRS$bestTune$lambda)
## 65 x 1 sparse Matrix of class "dgCMatrix"
## 1
## (Intercept) 0.003209575
## PC1_univ .
## PC2_univ .
## PC3_univ .
## PC1_sim .
## PC2_sim .
## PC3_sim .
## PC4_sim .
## PC5_sim .
## PC1_MVPA .
## PC2_MVPA .
## PC3_MVPA .
## PC4_MVPA .
## PC5_MVPA .
## PC6_MVPA .
## PC7_MVPA .
## PC8_MVPA .
## PC9_MVPA .
## PC10_MVPA .
## PC11_MVPA .
## PC12_MVPA .
## PC1_EEG .
## PC2_EEG .
## PC3_EEG .
## PC4_EEG .
## PC5_EEG 0.060370393
## PC6_EEG 0.056568670
## PC7_EEG .
## PC8_EEG .
## PC9_EEG -0.093181800
## PC10_EEG .
## PC11_EEG .
## PC12_EEG .
## PC13_EEG .
## PC1_RS .
## PC2_RS .
## PC3_RS .
## PC4_RS .
## PC5_RS .
## PC6_RS .
## PC7_RS .
## PC8_RS .
## PC1_struc .
## PC2_struc .
## PC3_struc .
## PC4_struc .
## PC5_struc .
## PC6_struc .
## PC7_struc .
## PC8_struc .
## PC9_struc .
## PC10_struc .
## PC11_struc .
## PC12_struc .
## PC13_struc .
## PC14_struc 0.017960903
## PC15_struc .
## PC16_struc .
## PC17_struc .
## PC18_struc .
## PC19_struc .
## PC20_struc .
## GENDER .
## AGE .
## SCANNER -0.117431632
# Make predictions
predictions.lasso.BPRS <- lasso.BPRS %>% predict(test.data_BPRS)
# Model prediction performance
data.frame(
RMSE = RMSE(predictions.lasso.BPRS, test.data_BPRS$BPRS),
#Rsquare = R2(predictions.lasso.BPRS, test.data_BPRS$BPRS)
Rsquare = calc_r_squared(lasso.BPRS, predictions.lasso.BPRS, test.data_BPRS$BPRS)
)
## Warning in pred - obs: longer object length is not a multiple of shorter object
## length
## Warning in cbind(preds, obs): number of rows of result is not a multiple of
## vector length (arg 1)
## RMSE Rsquare
## 1 0.9679567 0.0296161
elastic.BPRS <- train(
BPRS ~., data = train.data_BPRS, method = "glmnet",
trControl = trainControl("cv", number = 10, savePredictions = "all"),
tuneLength = 10
)
# Model coefficients
coef(elastic.BPRS$finalModel, elastic.BPRS$bestTune$lambda)
## 65 x 1 sparse Matrix of class "dgCMatrix"
## 1
## (Intercept) 5.602941e-03
## PC1_univ .
## PC2_univ 3.001699e-02
## PC3_univ 6.238010e-02
## PC1_sim 6.980116e-02
## PC2_sim .
## PC3_sim -2.241659e-02
## PC4_sim .
## PC5_sim -3.584391e-02
## PC1_MVPA 4.353832e-02
## PC2_MVPA -1.614261e-02
## PC3_MVPA 1.213406e-02
## PC4_MVPA 4.090952e-02
## PC5_MVPA -7.457436e-02
## PC6_MVPA .
## PC7_MVPA -4.930085e-02
## PC8_MVPA -2.442942e-02
## PC9_MVPA 3.973775e-02
## PC10_MVPA .
## PC11_MVPA .
## PC12_MVPA .
## PC1_EEG 1.008577e-01
## PC2_EEG -3.704441e-02
## PC3_EEG -5.371501e-03
## PC4_EEG -7.853368e-02
## PC5_EEG 1.401198e-01
## PC6_EEG 1.611834e-01
## PC7_EEG 4.401439e-02
## PC8_EEG .
## PC9_EEG -1.788925e-01
## PC10_EEG -5.418208e-02
## PC11_EEG 3.365096e-04
## PC12_EEG -1.275540e-01
## PC13_EEG 1.992829e-05
## PC1_RS -2.579115e-02
## PC2_RS -7.015573e-02
## PC3_RS .
## PC4_RS 2.774609e-02
## PC5_RS -9.534905e-02
## PC6_RS .
## PC7_RS .
## PC8_RS .
## PC1_struc .
## PC2_struc 4.319283e-02
## PC3_struc 6.707374e-02
## PC4_struc 5.901413e-02
## PC5_struc -8.699862e-02
## PC6_struc .
## PC7_struc -6.866452e-02
## PC8_struc 1.386708e-02
## PC9_struc 4.497339e-02
## PC10_struc 7.859724e-02
## PC11_struc 7.711225e-02
## PC12_struc 2.561098e-02
## PC13_struc -3.539252e-02
## PC14_struc 1.640184e-01
## PC15_struc 4.123028e-02
## PC16_struc 7.181317e-02
## PC17_struc .
## PC18_struc .
## PC19_struc -1.899458e-02
## PC20_struc -1.344555e-02
## GENDER .
## AGE 1.009307e-01
## SCANNER -1.614952e-01
# Make predictions
predictions.elastic.BPRS <- elastic.BPRS %>% predict(test.data_BPRS)
# Model prediction performance
data.frame(
RMSE = RMSE(predictions.elastic.BPRS, test.data_BPRS$BPRS),
#Rsquare = R2(predictions.elastic.BPRS, test.data_BPRS$BPRS)
Rsquare = calc_r_squared(elastic.BPRS, predictions.elastic.BPRS, test.data_BPRS$BPRS)
)
## Warning in pred - obs: longer object length is not a multiple of shorter object
## length
## Warning in cbind(preds, obs): number of rows of result is not a multiple of
## vector length (arg 1)
## RMSE Rsquare
## 1 1.030599 0.1069525
These models can explain less variance than in span - only about 6-12%. Just as with span, ridge regression is the best model.
models.BPRS <- list(ridge = ridge.BPRS, lasso = lasso.BPRS, elastic = elastic.BPRS, stepwise = step.BPRS)
resamples(models.BPRS) %>% summary( metric = "RMSE")
##
## Call:
## summary.resamples(object = ., metric = "RMSE")
##
## Models: ridge, lasso, elastic, stepwise
## Number of resamples: 10
##
## RMSE
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## ridge 0.6778879 0.7535039 0.9223314 0.9247342 0.9765231 1.397715 0
## lasso 0.6126031 0.7417970 0.8702359 0.9388938 0.9887172 1.555045 0
## elastic 0.7059086 0.8887469 0.9567720 0.9721424 1.0240311 1.344688 0
## stepwise 0.8375078 0.9737005 1.0437217 1.1353903 1.2999802 1.559785 0
resamples(models.BPRS) %>% summary( metric = "Rsquared")
##
## Call:
## summary.resamples(object = ., metric = "Rsquared")
##
## Models: ridge, lasso, elastic, stepwise
## Number of resamples: 10
##
## Rsquared
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## ridge 0.0002861828 0.04089539 0.06711898 0.11667171 0.14234974 0.4637613
## lasso 0.0001547026 0.04434508 0.06734173 0.07249737 0.08671737 0.1921424
## elastic 0.0016123492 0.02656582 0.07207702 0.11224186 0.15463667 0.4442100
## stepwise 0.0001503869 0.02552359 0.08940739 0.17273198 0.21450872 0.6363670
## NA's
## ridge 0
## lasso 0
## elastic 0
## stepwise 0
There are fewer things that are related to accuracy, and these seem to relate to the activity in the fusiform/other visual measures and performance measures at high load conditions. Interestingly, none of the components related to accuracy across all models come from resting state or similarity measures.
set.seed(123)
training.samples_high_acc <- reg_data$high_acc %>%
createDataPartition(p = 0.8, list = FALSE)
train.data_high_acc <- reg_data[training.samples_high_acc, c(3, 5:68)]
train.data_high_acc.impute <- preProcess(train.data_high_acc, method="knnImpute")
train.data_high_acc <- predict(train.data_high_acc.impute, train.data_high_acc)
test.data_high_acc <- reg_data[-training.samples_high_acc, c(3, 5:68)]
test.data_high_acc <- sapply(test.data_high_acc, scale)
test.data_high_acc <- data.frame(test.data_high_acc)
lambda <- 10^seq(-3, 3, length = 100)
step.high_acc <- train(high_acc ~., data = train.data_high_acc,
method = "lmStepAIC",
trControl = trainControl("cv", number = 10, savePredictions = "all"),
trace = FALSE
)
# Model accuracy
step.high_acc$results
## parameter RMSE Rsquared MAE RMSESD RsquaredSD MAESD
## 1 none 1.277731 0.1842656 1.05636 0.335653 0.1741718 0.2852715
# Final model coefficients
step.high_acc$finalModel
##
## Call:
## lm(formula = .outcome ~ PC1_univ + PC3_univ + PC1_sim + PC2_sim +
## PC3_sim + PC5_sim + PC2_MVPA + PC5_MVPA + PC8_MVPA + PC9_MVPA +
## PC10_MVPA + PC12_MVPA + PC3_EEG + PC4_EEG + PC7_EEG + PC10_EEG +
## PC12_EEG + PC13_EEG + PC5_RS + PC6_RS + PC8_RS + PC3_struc +
## PC6_struc + PC8_struc + PC9_struc + PC12_struc + PC15_struc +
## PC18_struc + PC19_struc + AGE, data = dat)
##
## Coefficients:
## (Intercept) PC1_univ PC3_univ PC1_sim PC2_sim PC3_sim
## 0.006832 0.146725 -0.133265 -0.149020 0.150990 0.115225
## PC5_sim PC2_MVPA PC5_MVPA PC8_MVPA PC9_MVPA PC10_MVPA
## 0.100130 0.102717 0.208702 0.104710 0.119211 -0.094692
## PC12_MVPA PC3_EEG PC4_EEG PC7_EEG PC10_EEG PC12_EEG
## -0.185715 0.101335 -0.130803 -0.202762 0.118205 0.313510
## PC13_EEG PC5_RS PC6_RS PC8_RS PC3_struc PC6_struc
## -0.227518 0.107309 -0.122339 -0.167793 0.107727 0.090510
## PC8_struc PC9_struc PC12_struc PC15_struc PC18_struc PC19_struc
## 0.190458 -0.097150 0.221413 0.151879 0.111625 0.130244
## AGE
## -0.138994
# Summary of the model
summary(step.high_acc$finalModel)
##
## Call:
## lm(formula = .outcome ~ PC1_univ + PC3_univ + PC1_sim + PC2_sim +
## PC3_sim + PC5_sim + PC2_MVPA + PC5_MVPA + PC8_MVPA + PC9_MVPA +
## PC10_MVPA + PC12_MVPA + PC3_EEG + PC4_EEG + PC7_EEG + PC10_EEG +
## PC12_EEG + PC13_EEG + PC5_RS + PC6_RS + PC8_RS + PC3_struc +
## PC6_struc + PC8_struc + PC9_struc + PC12_struc + PC15_struc +
## PC18_struc + PC19_struc + AGE, data = dat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.6881 -0.4350 0.0172 0.3728 1.4240
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.006832 0.061152 0.112 0.911259
## PC1_univ 0.146725 0.074282 1.975 0.050839 .
## PC3_univ -0.133265 0.073337 -1.817 0.072018 .
## PC1_sim -0.149020 0.076391 -1.951 0.053726 .
## PC2_sim 0.150990 0.069504 2.172 0.032056 *
## PC3_sim 0.115225 0.068673 1.678 0.096318 .
## PC5_sim 0.100130 0.070162 1.427 0.156486
## PC2_MVPA 0.102717 0.073585 1.396 0.165666
## PC5_MVPA 0.208702 0.069196 3.016 0.003205 **
## PC8_MVPA 0.104710 0.072748 1.439 0.152995
## PC9_MVPA 0.119211 0.067877 1.756 0.081930 .
## PC10_MVPA -0.094692 0.074576 -1.270 0.206960
## PC12_MVPA -0.185715 0.069222 -2.683 0.008469 **
## PC3_EEG 0.101335 0.076173 1.330 0.186263
## PC4_EEG -0.130803 0.069572 -1.880 0.062839 .
## PC7_EEG -0.202762 0.077849 -2.605 0.010520 *
## PC10_EEG 0.118205 0.071957 1.643 0.103405
## PC12_EEG 0.313510 0.078177 4.010 0.000113 ***
## PC13_EEG -0.227518 0.073061 -3.114 0.002373 **
## PC5_RS 0.107309 0.067463 1.591 0.114670
## PC6_RS -0.122339 0.070133 -1.744 0.083991 .
## PC8_RS -0.167793 0.068854 -2.437 0.016478 *
## PC3_struc 0.107727 0.066425 1.622 0.107820
## PC6_struc 0.090510 0.068136 1.328 0.186911
## PC8_struc 0.190458 0.071028 2.681 0.008503 **
## PC9_struc -0.097150 0.070464 -1.379 0.170881
## PC12_struc 0.221413 0.069592 3.182 0.001922 **
## PC15_struc 0.151879 0.066567 2.282 0.024512 *
## PC18_struc 0.111625 0.066594 1.676 0.096648 .
## PC19_struc 0.130244 0.067619 1.926 0.056765 .
## AGE -0.138994 0.070380 -1.975 0.050881 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.7139 on 106 degrees of freedom
## Multiple R-squared: 0.6028, Adjusted R-squared: 0.4904
## F-statistic: 5.363 on 30 and 106 DF, p-value: 5.492e-11
ridge.high_acc <- train(
high_acc ~., data = train.data_high_acc, method = "glmnet",
trControl = trainControl("cv", number = 10, savePredictions = "all"),
tuneGrid = expand.grid(alpha = 0, lambda = lambda)
)
## Warning in nominalTrainWorkflow(x = x, y = y, wts = weights, info = trainInfo, :
## There were missing values in resampled performance measures.
# Model coefficients
coef(ridge.high_acc$finalModel, ridge.high_acc$bestTune$lambda)
## 65 x 1 sparse Matrix of class "dgCMatrix"
## 1
## (Intercept) 0.0025974928
## PC1_univ 0.0859332761
## PC2_univ -0.0550805791
## PC3_univ -0.0688457744
## PC1_sim -0.0883922545
## PC2_sim 0.0325285333
## PC3_sim 0.0243092301
## PC4_sim 0.0038470589
## PC5_sim 0.0610626738
## PC1_MVPA 0.0025596934
## PC2_MVPA 0.0629739789
## PC3_MVPA -0.0129418632
## PC4_MVPA -0.0068774345
## PC5_MVPA 0.0892572494
## PC6_MVPA -0.0111728798
## PC7_MVPA 0.0101046675
## PC8_MVPA 0.0133932432
## PC9_MVPA 0.0370455089
## PC10_MVPA -0.0507133467
## PC11_MVPA 0.0204048482
## PC12_MVPA -0.0705947221
## PC1_EEG 0.0104256201
## PC2_EEG 0.0707507352
## PC3_EEG 0.0225948629
## PC4_EEG -0.0689811854
## PC5_EEG -0.0242299933
## PC6_EEG -0.0251206762
## PC7_EEG -0.0803135863
## PC8_EEG 0.0314831698
## PC9_EEG 0.0420532179
## PC10_EEG 0.0426225706
## PC11_EEG 0.0163522878
## PC12_EEG 0.1148207058
## PC13_EEG -0.0834694869
## PC1_RS 0.0294246061
## PC2_RS -0.0455945102
## PC3_RS -0.0314178395
## PC4_RS 0.0120497574
## PC5_RS 0.0559560952
## PC6_RS -0.0175790919
## PC7_RS -0.0392825303
## PC8_RS -0.0440552694
## PC1_struc -0.0143953839
## PC2_struc -0.0111210552
## PC3_struc 0.0637037352
## PC4_struc -0.0586905529
## PC5_struc -0.0071390245
## PC6_struc 0.0231227998
## PC7_struc -0.0240707058
## PC8_struc 0.0453698716
## PC9_struc -0.0008377079
## PC10_struc -0.0182081553
## PC11_struc -0.0257237855
## PC12_struc 0.0631102909
## PC13_struc -0.0538314220
## PC14_struc 0.0038061185
## PC15_struc 0.0839837966
## PC16_struc 0.0227775681
## PC17_struc 0.0186944542
## PC18_struc 0.0321155465
## PC19_struc 0.0169915978
## PC20_struc 0.0244971705
## GENDER -0.0286050011
## AGE -0.0584364484
## SCANNER -0.0088918180
# Make predictions
predictions.ridge.high_acc <- ridge.high_acc %>% predict(test.data_high_acc)
# Model prediction performance
data.frame(
RMSE = RMSE(predictions.ridge.high_acc, test.data_high_acc$high_acc),
#Rsquare = R2(predictions.ridge.high_acc, test.data_high_acc$high_acc)
Rsquare = calc_r_squared(ridge.high_acc, predictions.ridge.high_acc, test.data_high_acc$high_acc)
)
## Warning in pred - obs: longer object length is not a multiple of shorter object
## length
## Warning in cbind(preds, obs): number of rows of result is not a multiple of
## vector length (arg 1)
## RMSE Rsquare
## 1 1.114572 0.07498447
lasso.high_acc <- train(
high_acc ~., data = train.data_high_acc, method = "glmnet",
trControl = trainControl("cv", number = 10, savePredictions = "all"),
tuneGrid = expand.grid(alpha = 1, lambda = lambda)
)
## Warning in nominalTrainWorkflow(x = x, y = y, wts = weights, info = trainInfo, :
## There were missing values in resampled performance measures.
# Model coefficients
coef(lasso.high_acc$finalModel, lasso.high_acc$bestTune$lambda)
## 65 x 1 sparse Matrix of class "dgCMatrix"
## 1
## (Intercept) 0.0065249368
## PC1_univ 0.1742073343
## PC2_univ -0.0301658329
## PC3_univ -0.0625166885
## PC1_sim -0.1406211404
## PC2_sim .
## PC3_sim .
## PC4_sim .
## PC5_sim 0.0192807302
## PC1_MVPA .
## PC2_MVPA 0.0017943242
## PC3_MVPA .
## PC4_MVPA .
## PC5_MVPA 0.1237517582
## PC6_MVPA .
## PC7_MVPA .
## PC8_MVPA .
## PC9_MVPA .
## PC10_MVPA -0.0009125601
## PC11_MVPA .
## PC12_MVPA -0.0667460558
## PC1_EEG .
## PC2_EEG 0.0703980146
## PC3_EEG .
## PC4_EEG -0.0264805471
## PC5_EEG .
## PC6_EEG .
## PC7_EEG -0.0659903987
## PC8_EEG .
## PC9_EEG .
## PC10_EEG .
## PC11_EEG .
## PC12_EEG 0.1681023462
## PC13_EEG -0.0978098487
## PC1_RS .
## PC2_RS .
## PC3_RS .
## PC4_RS .
## PC5_RS 0.0258248744
## PC6_RS .
## PC7_RS .
## PC8_RS -0.0165797321
## PC1_struc .
## PC2_struc .
## PC3_struc 0.0287571524
## PC4_struc -0.0499533481
## PC5_struc .
## PC6_struc .
## PC7_struc .
## PC8_struc .
## PC9_struc .
## PC10_struc .
## PC11_struc .
## PC12_struc 0.0351100817
## PC13_struc -0.0140008377
## PC14_struc .
## PC15_struc 0.0823925482
## PC16_struc .
## PC17_struc .
## PC18_struc .
## PC19_struc .
## PC20_struc .
## GENDER .
## AGE -0.0298058071
## SCANNER .
# Make predictions
predictions.lasso.high_acc <- lasso.high_acc %>% predict(test.data_high_acc)
# Model prediction performance
data.frame(
RMSE = RMSE(predictions.lasso.high_acc, test.data_high_acc$high_acc),
#Rsquare = R2(predictions.lasso.high_acc, test.data_high_acc$high_acc)
Rsquare = calc_r_squared(lasso.high_acc, predictions.lasso.high_acc, test.data_high_acc$high_acc)
)
## Warning in pred - obs: longer object length is not a multiple of shorter object
## length
## Warning in cbind(preds, obs): number of rows of result is not a multiple of
## vector length (arg 1)
## RMSE Rsquare
## 1 1.04188 0.04659163
When we look at ElasticNet, all coefficients play a role. The most important ones seem to be:
elastic.high_acc <- train(
high_acc ~., data = train.data_high_acc, method = "glmnet",
trControl = trainControl("cv", number = 10, savePredictions = "all"),
tuneLength = 10
)
# Model coefficients
coef(elastic.high_acc$finalModel, elastic.high_acc$bestTune$lambda)
## 65 x 1 sparse Matrix of class "dgCMatrix"
## 1
## (Intercept) 0.0056874292
## PC1_univ 0.1374227474
## PC2_univ -0.0445886864
## PC3_univ -0.0750488977
## PC1_sim -0.1256614298
## PC2_sim 0.0100626257
## PC3_sim .
## PC4_sim .
## PC5_sim 0.0436484330
## PC1_MVPA .
## PC2_MVPA 0.0350261563
## PC3_MVPA .
## PC4_MVPA .
## PC5_MVPA 0.1117200550
## PC6_MVPA .
## PC7_MVPA .
## PC8_MVPA .
## PC9_MVPA 0.0072182550
## PC10_MVPA -0.0237335937
## PC11_MVPA .
## PC12_MVPA -0.0761537589
## PC1_EEG .
## PC2_EEG 0.0747206663
## PC3_EEG .
## PC4_EEG -0.0520060964
## PC5_EEG .
## PC6_EEG .
## PC7_EEG -0.0858844679
## PC8_EEG .
## PC9_EEG 0.0207190906
## PC10_EEG 0.0201360871
## PC11_EEG .
## PC12_EEG 0.1525851911
## PC13_EEG -0.1101335380
## PC1_RS 0.0003729976
## PC2_RS -0.0185186479
## PC3_RS -0.0111112681
## PC4_RS .
## PC5_RS 0.0474215890
## PC6_RS .
## PC7_RS -0.0092604064
## PC8_RS -0.0344807029
## PC1_struc .
## PC2_struc .
## PC3_struc 0.0478187721
## PC4_struc -0.0585112972
## PC5_struc .
## PC6_struc 0.0048435466
## PC7_struc .
## PC8_struc 0.0230723845
## PC9_struc .
## PC10_struc .
## PC11_struc -0.0006548628
## PC12_struc 0.0585744609
## PC13_struc -0.0353534515
## PC14_struc .
## PC15_struc 0.0867417781
## PC16_struc .
## PC17_struc .
## PC18_struc .
## PC19_struc .
## PC20_struc .
## GENDER .
## AGE -0.0519733528
## SCANNER .
# Make predictions
predictions.elastic.high_acc <- elastic.high_acc %>% predict(test.data_high_acc)
# Model prediction performance
data.frame(
RMSE = RMSE(predictions.elastic.high_acc, test.data_high_acc$high_acc),
#Rsquare = R2(predictions.elastic.high_acc, test.data_high_acc$high_acc)
Rsquare = calc_r_squared(elastic.high_acc, predictions.elastic.high_acc, test.data_high_acc$high_acc)
)
## Warning in pred - obs: longer object length is not a multiple of shorter object
## length
## Warning in cbind(preds, obs): number of rows of result is not a multiple of
## vector length (arg 1)
## RMSE Rsquare
## 1 1.059903 0.08950036
These models explain the most variance - 15-26% of the variance. Here, ElasticNet and Ridge are our best models, with ElasticNet explaining more variance but ridge having a lower error.
models.high_acc <- list(ridge = ridge.high_acc, lasso = lasso.high_acc, elastic = elastic.high_acc, stepwise = step.high_acc)
resamples(models.high_acc) %>% summary( metric = "RMSE")
##
## Call:
## summary.resamples(object = ., metric = "RMSE")
##
## Models: ridge, lasso, elastic, stepwise
## Number of resamples: 10
##
## RMSE
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## ridge 0.6795633 0.7920482 0.8612487 0.8823796 0.8859584 1.168287 0
## lasso 0.6840209 0.8340848 0.8776111 0.9121972 1.0243921 1.085529 0
## elastic 0.7380298 0.8630158 0.9074712 0.9074259 0.9837880 1.102101 0
## stepwise 0.7295087 1.0559950 1.3035355 1.2777312 1.4556930 1.935389 0
resamples(models.high_acc) %>% summary( metric = "Rsquared")
##
## Call:
## summary.resamples(object = ., metric = "Rsquared")
##
## Models: ridge, lasso, elastic, stepwise
## Number of resamples: 10
##
## Rsquared
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## ridge 0.019465672 0.16408092 0.2334328 0.2405885 0.3311543 0.4149402 0
## lasso 0.038040612 0.14470559 0.1849042 0.1889012 0.2443673 0.2866066 0
## elastic 0.005521057 0.11663970 0.2599147 0.2482464 0.3047524 0.7458056 0
## stepwise 0.003066266 0.02455944 0.1582682 0.1842656 0.2888692 0.4738086 0